我有一个列表,我需要删除"基因-"无论它发生在哪里。我试过
lapply(net, FUN = function(x) setNames(x, sub("gene-","", x)))
但我得到了错误
名称错误(对象)〈-nm:尝试将属性设置为NULL
head(net)
$colors
gene-AAAS gene-AAK1 gene-AAMDC gene-AAMP gene-AARS1 gene-AASDH
"magenta" "brown" "purple" "darkgrey" "brown" "blue"
gene-AASDHPPT gene-AASS gene-AATK gene-ABAT
[ reached getOption("max.print") -- omitted 8990 entries ]
$unmergedColors
gene-AAAS gene-AAK1 gene-AAMDC gene-AAMP gene-AARS1 gene-AASDH
"darkgrey" "blue" "magenta" "darkolivegreen" "blue" "brown"
gene-AASDHPPT gene-AASS gene-AATK gene-ABAT gene-ABCA1 gene-ABCA12
"lightyellow" "lightgreen" "turquoise" "darkred" "turquoise" "grey60"
[ reached getOption("max.print") -- omitted 8990 entries ]
$MEs
MEblack MEgreenyellow MElightcyan MEyellow MEturquoise MEpink MEwhite MEdarkred
M5 -0.17423916 0.141440817 0.23401244 0.36358728 -0.0220835 -0.18126013 0.05942248 -0.45035371
N3 0.47690393 0.428961135 0.07241255 -0.02557197 0.2238352 0.06742087 -0.09574663 0.52201599
$goodSamples
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
$goodGenes
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
[ reached getOption("max.print") -- omitted 8990 entries ]
$dendrograms
$dendrograms[[1]]
Call:
fastcluster::hclust(d = as.dist(dissTom), method = "average")
Cluster method : average
Number of objects: 9990
产出(净额)
166L, 5768L, 2346L, 7132L, 625L, 4848L, 736L, 7001L,
1721L, 6626L, 7674L, 2543L, 7013L, 8667L, 4593L, 2804L,
....
7435L, 4895L, 8462L, 1732L, 3160L, 8529L), labels = NULL,
method = "average", call = fastcluster::hclust(d = as.dist(dissTom),
method = "average"), dist.method = NULL), class = "hclust")),
TOMFiles = NULL, blockGenes = list(1:9990), blocks = c(1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
...
1, 1), MEsOK = TRUE)
1条答案
按热度按时间zfycwa2u1#
您的代码几乎可以正常工作,但您需要做两个更改:
1.我们想修改 names,所以内部函数需要读取
names(x)
:net
包含很多成员,你只想替换colors
和unmergedColors
成员,所以只对它们应用你的函数,哦,你需要把结果赋回你的对象: