1. 发现报错
在进行monocle2发育轨迹的时候,从来么有报错的软件,竟然罢工了,出现了如下报错:
pData(HSMM_myo)$Total_mRNAs <- Matrix::colSums(exprs(HSMM_myo))
检查报错:
exprs(HSMM_myo)
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘exprs’ for signature ‘"CellDataSet"’
HSMM_myo
CellDataSet (storageMode: environment)
assayData: 19055 features, 12856 samples
element names: exprs
protocolData: none
phenoData
sampleNames: AAACCTGAGAAGGACA-1.CM022-2-1
AAACCTGAGACAAGCC-1.CM022-2-1 ... TTTGTCATCTGGCGTG-1.CM022-2-1
(12856 total)
varLabels: orig.ident nCount_RNA ... Size_Factor (96 total)
varMetadata: labelDescription
featureData
featureNames: Mrpl15 Lypla1 ... Gm14379 (19055 total)
fvarLabels: gene_short_name
fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
Annotation:
这说明不是monocle2对象的问题,可能是函数的问题?
exprs
standardGeneric for "exprs" defined from package "monocle3"
function (x)
standardGeneric("exprs")
<bytecode: 0x51240ad0>
<environment: 0x5123d698>
Methods may be defined for arguments: x
Use showMethods(exprs) for currently available ones.
原来问题出在这里,exprs这里默认的是monocle3定义的函数,但monocle3与monocle2可能不一样,因此这里需要改一下,使用标准的函数,具体如下:
Biobase::exprs
standardGeneric for "exprs" defined from package "Biobase"
function (object)
standardGeneric("exprs")
<bytecode: 0x6f5c7c0>
<environment: 0x6f61448>
Methods may be defined for arguments: object
Use showMethods(exprs) for currently available ones.
> str(exprs(HSMM_myo))
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘exprs’ for signature ‘"CellDataSet"’
> str(Biobase::exprs(HSMM_myo))
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
..@ i : int [1:17615233] 0 2 10 33 35 61 66 100 108 119 ...
..@ p : int [1:12857] 0 1721 2404 3147 3683 7653 8219 8681 9273 9734 ...
..@ Dim : int [1:2] 19055 12856
..@ Dimnames:List of 2
.. ..$ : chr [1:19055] "Mrpl15" "Lypla1" "Tcea1" "Rgs20" ...
.. ..$ : chr [1:12856] "AAACCTGAGAAGGACA-1.CM022-2-1" "AAACCTGAGACAAGCC-1.CM022-2-1" "AAACCTGAGACCTAGG-1.CM022-2-1" "AAACCTGAGAGAACAG-1.CM022-2-1" ...
..@ x : num [1:17615233] 1 1 2 1 11 1 1 1 1 1 ...
..@ factors : list()
总结
最终命令改成了如下形式:
pData(HSMM_myo)$Total_mRNAs <- Matrix::colSums(Biobase::exprs(HSMM_myo))
虽然这个报错只是一个小问题,但是这个问题提示我们,不同的R包的版本不一样,可能函数也不一样,如果需要使用不同版本的同一个R包,可以考虑通过conda多构建几个环境。