# #——包括= FALSE --------------------------------------------------------- knitr: opts_chunk美元集(崩溃= TRUE,评论= " # > "。宽度=“100%”,fig.width = 7, fig.height = 5, dpi = 300, fig.path =“数据/ BayesSpace -”,消息= FALSE,警告= FALSE,错误= FALSE ) ## ---- 设置 -------------------------------------------------------------------- 库(SingleCellExperiment)图书馆(ggplot2)图书馆(BayesSpace) # #——readVisium,eval = FALSE --------------------------------------------------- # 南加州爱迪生公司< - readVisium(“路径/ / spaceranger出局 /") ## ---- 下载 ----------------------------------------------------------------- 黑色素瘤< - getRDS(数据集=“2018 _thrane_melanoma”示例= " ST_mel1_rep2 ") ## ---- 手册。sce, eval=FALSE--------------------------------------------------- # library(Matrix) # # rowData <- read.csv("path/to/rowData.csv", stringsAsFactors=FALSE) # colData <- read.csv("path/to/colData.csv", stringsAsFactors=FALSE, row.names=1) # counts <- read.csv("path/to/colData.csv", stringsAsFactors=FALSE, row.names .gz", # row.names=1, check.names=F, stringsAsFactors=FALSE)) # sce <- singlecel实验(assays=list(counts=as(counts, "dgCMatrix")), # rowData=rowData,# colData = colData) # #——进行预处理 --------------------------------------------------------------- 黑色素瘤set.seed (102) < - spatialPreprocess(黑色素瘤,平台=“圣”,n.PCs = 7, n.HVGs = 2000, log.normalize = FALSE) # #——tuning_q ----------------------------------------------------------------- 黑色素瘤< - qTune(黑色素瘤,qs = seq(10),平台=“圣”,d = 7) qPlot(黑色素瘤)# #——集群 ------------------------------------------------------------------ 黑色素瘤set.seed (149) < - spatialCluster(黑色素瘤,q = 4,平台=“圣”,d = 7, init。方法="mclust",模型="t", gamma=2, nrep=1000,燃烧。in=100, save.chain=TRUE) ## ----集群。结果 ---------------------------------------------------------- 头(colData(黑色素瘤 )) ## ---- 集群。情节,fig.width = 7, fig.height = 5 ---------------------------------- clusterPlot(黑色素瘤)# #——cluster.plot。定制,fig.width = 7, fig.height = 5 ------------------------ clusterPlot(黑色素瘤,面板= c(“紫色”、“红”“蓝”、“黄色”),颜色=“黑色”)+ theme_bw () + xlab(“列”)+ ylab(“行”)+实验室(填补=“BayesSpace \ ncluster ST_mel1_rep2 title =“空间聚类 ") ## ---- 提高,eval = TRUE ------------------------------------------------------- 黑素瘤。增强<- spatialEnhance(黑色素瘤,q=4,平台="ST", d=7,模型="t", gamma=2, jitter_prior=0.3, jitter_scale=3.5, nrep=1000,烧伤。in=100, save.chain=TRUE) ## ----增强。结果 ---------------------------------------------------------- 头(colData (melanoma.enhanced )) ## ---- 提高。plot, eval=TRUE, fig.width=7, fig.height=5----------------------- clusterPlot(melanoma.enhanced) ## ----enhanceFeatures---------------------------------------------------------- markers <- c("PMEL", "CD2", "CD19", "COL1A1") melanoma.enhanced <- enhanceFeatures(melanoma.enhanced, melanoma, feature_names=markers, nrounds=0) ## ----enhanced.logcount-------------------------------------------------------- logcounts(melanoma.enhanced)[markers, 1:5] ## ----enhanced.rmse------------------------------------------------------------ rowData(melanoma.enhanced)[markers, ] ## ----enhanced.featurePlot----------------------------------------------------- featurePlot(melanoma.enhanced, "PMEL") ## ----enhanced.markers, fig.width=12, fig.height=8----------------------------- enhanced.plots <- purrr::map(markers, function(x) featurePlot(melanoma.enhanced, x)) patchwork::wrap_plots(enhanced.plots, ncol=2) ## ----compare.resolution, fig.width=16, fig.height=8--------------------------- spot.plots <- purrr::map(markers, function(x) featurePlot(melanoma, x)) patchwork::wrap_plots(c(enhanced.plots, spot.plots), ncol=4) ## ----mcmcChain, eval=TRUE----------------------------------------------------- chain <- mcmcChain(melanoma) chain[1:5, 1:5]