我必须应用我不想将它们组合成一个函数的函数。
list1 <- lapply(seq(1,100), function(x) topFeaturesAllSamples[[x]])
list2 <- lapply(seq(1,100), function(x) list1[[x]][topDifferentialExpressed[[x]][[1]],])
list1是100的清单 在每个列表中包含不同的基因表达
[[1]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
RNF38 9.184958 9.038283 9.625290 9.361620 9.427665
EIF5AL1 11.796275 12.350587 11.327539 10.889184 10.994424
WRAP53 8.216806 9.088202 7.750620 7.578281 7.648888
[[2]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
WRAP53 8.216806 9.088202 7.750620 7.578281 7.648888
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
YAP1 11.086030 11.162294 10.848429 11.058929 9.836591
TMEM43 10.732424 10.765218 11.214908 11.106273 10.508263
list2也是100的列表,表示list1 [[1]]
的一部分 [[1]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
[[2]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
RNF38 9.184958 9.038283 9.625290 9.361620 9.427665
[[3]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
RNF38 9.184958 9.038283 9.625290 9.361620 9.427665
EIF5AL1 11.796275 12.350587 11.327539 10.889184 10.994424
问题是我希望有一个函数重复list1的lapply 198次 所以de [[x]] [[1]]背后的数字必须在每次迭代时改变 所以而不是
list2 <- lapply(seq(1,100), function(x) list1[[x]][topDifferentialExpressed[[x]][[1]],])
list2.1 <- lapply(seq(1,100), function(x) list1[[x]][topDifferentialExpressed[[x]][[2]],])
list2.2 <- lapply(seq(1,100), function(x) list1[[x]][topDifferentialExpressed[[x]][[3]],])
....
....
list2.198 <- lapply(seq(1,100), function(x) list1[[x]][topDifferentialExpressed[[x]][[198]],])
所以list2.1看起来应该是这样的
[[1]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
WRAP53 8.216806 9.088202 7.750620 7.578281 7.648888
[[2]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
WRAP53 8.216806 9.088202 7.750620 7.578281 7.648888
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
[[3]]
TCGA-AG-A016 TCGA-AG-3887 TCGA-AG-3581 TCGA-AG-A00C TCGA-AG-3594
TGFBR2 11.407178 10.987474 11.704051 10.711772 11.861520
MAML2 7.080093 7.789335 7.713779 8.645695 6.777620
WRAP53 8.216806 9.088202 7.750620 7.578281 7.648888
EIF5A 13.724940 14.222748 13.018575 12.640773 12.604787
YAP1 11.086030 11.162294 10.848429 11.058929 9.836591
对于list1中的所有198个列表,我应该重复这个等等。我希望有一个函数重复这个过程198次。
我已经尝试过双循环,这导致我的R卡住了。
我希望最终有1个包含198个列表的列表,198个列表中的每个列表还应包含100个包含每个列表的基因表达式的列表
有一种有效的方法吗?