我有一组具有SCEset格式的单细胞RNAseq数据,并使用sc3包进行聚类分析。
代码:
Count <- sc3_prepare(Data, ks = 2:5)
Count <- sc3_estimate_k(Count)
Count@sc3$k_estimation
Count <- sc3(Count, ks = 5, biology = TRUE)
使用plotTSNE
函数很容易显示tSNE图。但是,我不知道如何在tSNE图中绘制特定基因表达的分布。
我尝试了以下代码,但它没有工作:
tsne_colplot <- function(gene_name) {
df <- as.numeric(Data[grep(paste0("^",gene_name,"$"),rownames(Data)),])
col <- c("lightgray","orange","red")
colAlpha <- add.alpha(col, alpha=0.1)
(colc <- cut(df, breaks = c(0, 1, 100, Inf), include.lowest = TRUE))
plotTSNE(Count, rand_seed = 123456, colour_by = col[colc], main=gene_name)
}
add.alpha <- function(col, alpha=1) {
if(missing(col))
stop("Please provide a vector of colours.")
apply(sapply(col, col2rgb)/255, 2, function(x)
rgb(x[1], x[2], x[3], alpha=alpha))
}