大家好,这几天在学习单细胞测序,遇到几个问题,一直解决不了,请各位帮帮忙看一下
第一个问题是为什么标准差为零,我使用的跟教程完全一致的操作和代码,但是总是显示标准差为0,结果图片直接是一条横线
setwd("F:\\shengxin\\wenjian\\1") #设置工作目录
>
> #读取文件,并对重复基因取均值
> rt=read.table("geneMatrix.txt",sep="\t",header=T,check.names=F)
> rt=as.matrix(rt)
> rownames(rt)=rt[,1]
> exp=rt[,2:ncol(rt)]
> dimnames=list(rownames(exp),colnames(exp))
> data=matrix(as.numeric(as.matrix(exp)),nrow=nrow(exp),dimnames=dimnames)
> data=avereps(data)
>
> #将矩阵转换为Seurat对象,并对数据进行过滤
> pbmc <- CreateSeuratObject(counts = data,project = "seurat", min.cells = 3, min.features = 50, names.delim = "_",)
Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-')
> #使用PercentageFeatureSet函数计算线粒体基因的百分比
> pbmc[["percent.mt"]] <- PercentageFeatureSet(object = pbmc, pattern = "^MT-")
> pdf(file="04.featureViolin.pdf",width=10,height=6) #保存基因特征小提琴图
> VlnPlot(object = pbmc, features = c("nFeature_RNA", "nCount_RNA", "percent.mt"), ncol = 3)
Warning message:
In SingleExIPlot(type = type, data = data[, x, drop = FALSE], idents = idents, :
All cells have the same value of percent.mt.
> dev.off()
null device
1
> pbmc <- subset(x = pbmc, subset = nFeature_RNA > 50 & percent.mt < 5) #对数据进行过滤
>
> #测序深度的相关性绘图
> pdf(file="04.featureCor.pdf",width=10,height=6) #保存基因特征相关性图
> plot1 <- FeatureScatter(object = pbmc, feature1 = "nCount_RNA", feature2 = "percent.mt",pt.size=1.5)
Warning message:
In cor(x = data[, 1], y = data[, 2]) : 标准差为零
> plot2 <- FeatureScatter(object = pbmc, feature1 = "nCount_RNA", feature2 = "nFeature_RNA",,pt.size=1.5)
> CombinePlots(plots = list(plot1, plot2))
Warning message:
CombinePlots is being deprecated. Plots should now be combined using the patchwork system.
> dev.off()
pbmc <- RunTSNE(object = pbmc, dims = 1:pcSelect) #TSNE聚类
> pdf(file="06.TSNE.pdf",width=6.5,height=6)
> TSNEPlot(object = pbmc, do.label = TRUE, pt.size = 2, label = TRUE) #TSNE可视化
Error in DimPlot(object = new("Seurat", assays = list(RNA = new("Assay", :
参数没有用(do.label = TRUE)
> dev.off()
##寻找差异表达的特征
> logFCfilter=0.5
> adjPvalFilter=0.05
> pbmc.markers <- FindAllMarkers(object = pbmc,
+ only.pos = FALSE,
+ min.pct = 0.25,
+ logfc.threshold = logFCfilter)
sig.markers=pbmc.markers[(abs(as.numeric(as.vector(pbmc.markers$avg_logFC)))>logFCfilter & as.numeric(as.vector(pbmc.markers$p_val_adj)) write.table(sig.markers,file="06.markers.xls",sep="\t",row.names=F,quote=F)
>
> top10 <- pbmc.markers %>% group_by(cluster) %>% top_n(n = 10, wt = avg_logFC)
Error in `filter()`:
i In argument: `top_n_rank(10, avg_logFC)`.
i In group 1: `cluster = 0`.
Caused by error:
! 找不到对象'avg_logFC'
Run `rlang::last_error()` to see where the error occurred.
谢谢各位。
你把源码发给我看一下
数据集本身有没有什么问题,感觉代码输出很奇怪
一样的课,一样的问题