植物空間轉(zhuǎn)錄組分析 3:hdWGCNA

植物空間轉(zhuǎn)錄組分析1:Seurat基本流程 - 簡書 (jianshu.com)

植物空間轉(zhuǎn)錄組分析2:STEEL+Seurat - 簡書 (jianshu.com)

植物空間轉(zhuǎn)錄組分析 3:hdWGCNA - 簡書 (jianshu.com)

前言

時(shí)隔半年的更新,這次的主題是單細(xì)胞hdWGCNA分析,文章剛剛被接收,目前在植物空間轉(zhuǎn)錄組已經(jīng)有文章使用了該方法勺卢,基本的內(nèi)容就是分module然后去看每個(gè)module的hub基因搁宾,或者做做GO富集之類的

image.png

R包安裝以及數(shù)據(jù)準(zhǔn)備

本次分析還是以蘭花的空間轉(zhuǎn)錄組為基礎(chǔ)稀颁,具體的數(shù)據(jù)參考以前的推文

# install BiocManager
install.packages("BiocManager")

# install Bioconductor core packages
BiocManager::install()

# install additional packages:
install.packages(c("Seurat", "WGCNA", "igraph", "devtools"))

devtools::install_github('smorabit/hdWGCNA', ref='dev')

大家可能會(huì)因?yàn)榫W(wǎng)絡(luò)問題無法下載表锻,我直接將壓縮包發(fā)給大家


## 數(shù)據(jù)準(zhǔn)備
## 將spot坐標(biāo)信息加到metadata中
# make a dataframe containing the image coordinates for each sample
image_df <- do.call(rbind, lapply(names(orc1_new@images), function(x){
  orc1_new@images[[x]]@coordinates
}))

# merge the image_df with the Seurat metadata
new_meta <- merge(orc1_new@meta.data, image_df, by='row.names')

# fix the row ordering to match the original seurat object
rownames(new_meta) <- new_meta$Row.names
ix <- match(as.character(colnames(orc1_new)), as.character(rownames(new_meta)))
new_meta <- new_meta[ix,]

# add the new metadata to the seurat object
orc1_new@meta.data <- new_meta

構(gòu)建metaspots

## Here we set up the data for hdWGCNA and run MetaspotsByGroups. 

subdata <- subset(orc1_new, idents = c(19,21,37,38,39,40))
subdata <- SCTransform(subdata, assay = "Spatial", return.only.var.genes = FALSE, verbose = FALSE)
subdata <- RunPCA(subdata, features = VariableFeatures(subdata)) 

subdata <- SetupForWGCNA(
  subdata,
  features = VariableFeatures(subdata),
  wgcna_name = "SCT"
)


subdata <- MetacellsByGroups(
  seurat_obj = subdata,
  group.by = c("seurat_clusters"),
  k = 5,
  max_shared= 10,
  min_cells = 6,
  reduction = 'pca',
  ident.group = 'seurat_clusters',
  slot = 'scale.data',
  assay = 'SCT'
)
m_obj <- GetMetacellObject(subdata)
m_obj
An object of class Seurat 
14006 features across 180 samples within 1 assay 
Active assay: SCT (14006 features, 0 variable features)

這里需要注意,一般空間分析推薦使用的是 MetaspotsByGroups函數(shù)们衙,我嘗試了一遍softpower只有1,module只有兩個(gè)碱呼,所以又使用了MetacellsByGroups函數(shù)嘗試蒙挑。

共表達(dá)網(wǎng)絡(luò)分析

# set up the expression matrix, set group.by and group_name to NULL to include all spots
subdata  <- SetDatExpr(
  subdata,
  group.by=NULL,
  group_name = NULL
)

# test different soft power thresholds
subdata <- TestSoftPowers(subdata)
plot_list <- PlotSoftPowers(subdata)

wrap_plots(plot_list, ncol=2)

image.png
# construct co-expression network:
subdata <- ConstructNetwork(
  subdata,
  soft_power = 1,
  tom_name='test',
  overwrite_tom=TRUE
)

# plot the dendrogram
PlotDendrogram(subdata, main='Spatial hdWGCNA dendrogram')
image.png

compute module eigengenes

subdata <- ModuleEigengenes(subdata)
subdata <- ModuleConnectivity(subdata)

modules <- GetModules(subdata) %>% subset(module != 'grey')
head(modules[,1:3])

              gene_name    module     color
PAXXG297280 PAXXG297280 turquoise turquoise
PAXXG074500 PAXXG074500      blue      blue
PAXXG239080 PAXXG239080 turquoise turquoise
PAXXG067750 PAXXG067750 turquoise turquoise
PAXXG327430 PAXXG327430 turquoise turquoise
PAXXG311150 PAXXG311150      blue      blue

模塊數(shù)目比較少也是正常的

Data visualization

tom<-GetTOM(subdata)
##Data visualization
##Here we visualize module eigengenes using the Seurat functions DotPlot and SpatialFeaturePlot. 
##For network visualization, please refer to the Network visualization tutorial.
# get module eigengenes and gene-module assignment tables
MEs <- GetMEs(subdata)
modules <- GetModules(subdata)
mods <- levels(modules$module)

write.table(file="modules.xls",modules,row.names = F,sep="\t")
# plot with Seurat's DotPlot function
p <- DotPlot(subdata, features=mods, group.by = 'seurat_clusters', dot.min=0.1)

# flip the x/y axes, rotate the axis labels, and change color scheme:
p <- p +
  coord_flip() +
  RotatedAxis() +
  scale_color_gradient2(high='red', mid='grey95', low='blue') +
  xlab('') + ylab('')

p



p <- SpatialFeaturePlot(
  subdata,
  features = mods,
  ncol = 4,
  pt.size.factor = 3.5
)

p

image.png

image.png

module network plots

分為兩種,一種每個(gè)模塊的hubgene愚臀,一種是全部模塊的hubgene

## Individual module network plots
ModuleNetworkPlot(subdata,
                  plot_size = c(10, 10),
                  vertex.label.cex = 0.6
                  )

hub_df <- GetHubGenes(subdata, n_hubs = 25)
write.table(file="hub_df.xls",hub_df,row.names = F,sep="\t")

## hubgene network


HubGeneNetworkPlot(
  subdata,
  n_hubs = 4, n_other=6,
  edge_prop = 0.75,
  mods = 'all',
  hub.vertex.size = 4,
  other.vertex.size = 1,
  edge.alpha = 0.5
)


image.png

總結(jié)

目前只是初步上手忆蚀,其實(shí)這個(gè)方法主要的目的還是根據(jù)表達(dá)對基因進(jìn)行聚類,再加個(gè)功能富集可能會(huì)更好,后續(xù)還有UMAP to co-expression networks流程馋袜,但因?yàn)槲以谧龅臅r(shí)候效果比較差所以沒放男旗。

轉(zhuǎn)載請注明>>>周小釗的博客, 打賞推薦博客

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市欣鳖,隨后出現(xiàn)的幾起案子察皇,更是在濱河造成了極大的恐慌,老刑警劉巖泽台,帶你破解...
    沈念sama閱讀 217,185評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件什荣,死亡現(xiàn)場離奇詭異,居然都是意外死亡师痕,警方通過查閱死者的電腦和手機(jī)溃睹,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,652評論 3 393
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來胰坟,“玉大人因篇,你說我怎么就攤上這事”屎幔” “怎么了竞滓?”我有些...
    開封第一講書人閱讀 163,524評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長吹缔。 經(jīng)常有香客問我商佑,道長,這世上最難降的妖魔是什么厢塘? 我笑而不...
    開封第一講書人閱讀 58,339評論 1 293
  • 正文 為了忘掉前任茶没,我火速辦了婚禮,結(jié)果婚禮上晚碾,老公的妹妹穿的比我還像新娘抓半。我一直安慰自己,他們只是感情好格嘁,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,387評論 6 391
  • 文/花漫 我一把揭開白布笛求。 她就那樣靜靜地躺著,像睡著了一般糕簿。 火紅的嫁衣襯著肌膚如雪探入。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,287評論 1 301
  • 那天懂诗,我揣著相機(jī)與錄音蜂嗽,去河邊找鬼。 笑死殃恒,一個(gè)胖子當(dāng)著我的面吹牛徒爹,可吹牛的內(nèi)容都是我干的荚醒。 我是一名探鬼主播,決...
    沈念sama閱讀 40,130評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼隆嗅,長吁一口氣:“原來是場噩夢啊……” “哼界阁!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起胖喳,我...
    開封第一講書人閱讀 38,985評論 0 275
  • 序言:老撾萬榮一對情侶失蹤泡躯,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后丽焊,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體较剃,經(jīng)...
    沈念sama閱讀 45,420評論 1 313
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,617評論 3 334
  • 正文 我和宋清朗相戀三年技健,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了写穴。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,779評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡雌贱,死狀恐怖啊送,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情欣孤,我是刑警寧澤馋没,帶...
    沈念sama閱讀 35,477評論 5 345
  • 正文 年R本政府宣布,位于F島的核電站降传,受9級特大地震影響篷朵,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜婆排,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,088評論 3 328
  • 文/蒙蒙 一声旺、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧段只,春花似錦艾少、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,716評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽幔妨。三九已至鹦赎,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間误堡,已是汗流浹背古话。 一陣腳步聲響...
    開封第一講書人閱讀 32,857評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留锁施,地道東北人陪踩。 一個(gè)月前我還...
    沈念sama閱讀 47,876評論 2 370
  • 正文 我出身青樓杖们,卻偏偏與公主長得像,于是被迫代替她去往敵國和親肩狂。 傳聞我的和親對象是個(gè)殘疾皇子摘完,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,700評論 2 354

推薦閱讀更多精彩內(nèi)容