單細(xì)胞數(shù)據(jù)擬時(shí)序分析-destiny

單細(xì)胞數(shù)據(jù)分析常用到建立trajectory和pseudoTime,擬時(shí)序分析可以用 Diffusion( Destiny R package)

#Diffusion PseudoTime  Analysis
library(destiny) # 加載 destiny...
data(guo_norm) # 測(cè)試用的data
class(guo_norm)
image.png
dm <- DiffusionMap(ct,k = 3)
plot(dm)
image.png

給每個(gè)細(xì)胞添加注釋信息,如這個(gè)細(xì)胞的類型或者屬于的類群

palette(cube_helix(6)) #用cube_helix創(chuàng)建連續(xù)的顏色
#palette(hue_pal()(6))#也可以用ggplot2里面的默認(rèn)顏色
plot(dm, pch = 20, # pch for prettier points
col_by = 'num_cells', # or “col” with a vector or one color
legend_main = 'Cell stage')
image.png
#2D plot
plot(dm, 1:2, pch = 20, col_by = 'num_cells',
legend_main = 'Cell stage')
image.png
#3D plot
library(rgl)
plot3d(eigenvectors(dm)[, 1:3],
col = log2(guo_norm$num_cells),
type = 's', radius = .01)
view3d(theta = 10, phi = 30, zoom = .8)
# now use your mouse to rotate the plot in the window
rgl.close()
image.png

同樣可以用ggplot畫出來

qplot(DC1, DC2, data = dm, colour = factor(num_cells)) +
scale_color_cube_helix()
image.png
# or alternatively:
dif<-fortify(dm)#轉(zhuǎn)化為data.frame
ggplot(dif, aes(DC1, DC2, color = factor(num_cells)))+geom_point()
image.png
#plot 特征值
plot(eigenvalues(dm), ylim = 0:1, pch = 20,
xlab = 'Diffusion component (DC)', ylab = 'Eigenvalue')
image.png

detiny的數(shù)據(jù)輸入格式為Biobase包建立的ExpressionSet格式的文件,如果我們的數(shù)據(jù)是表達(dá)矩陣,則數(shù)據(jù)需要轉(zhuǎn)化成這個(gè)格式,如seurat包里面的數(shù)據(jù)Seurat.object可以這樣轉(zhuǎn)化:

library(Biobase)
ct <-GetAssayData(object = Seurat.object)
ct<-ct[VariableFeatures(Seurat.object),]
ct <- as.ExpressionSet(as.data.frame(t(ct)))
#添加注釋信息
#. Annotations can be accessed directly via ct$column and ct[['column']]. 
ct$celltype <- DPT@meta.data[,c("integrated_merge_cluster")]
dm <- DiffusionMap(ct,k = 10)
palette(cube_helix(4)) # configure color palette
plot(dm, pch = 20, # pch for prettier points
col_by = "celltype")
image.png

歡迎關(guān)注微信公眾號(hào)~


image.png

參考:
[http://10.30.30.253:8787/help/library/destiny/doc/Diffusion-Maps.pdf]
[https://bioconductor.org/packages/release/bioc/vignettes/destiny/inst/doc/DPT.pdf]
https://broadinstitute.github.io/2019_scWorkshop/functional-pseudotime-analysis.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容