我有一个数据集,它是一个大的字符向量(1,024,459个元素),由基因ID组成。看上去:
> length(allres)
[1] 1024459
>allres[1:10]
[1] "1" "1" "1" "1" "1" "1" "1" "10" "10" "100" 每个基因ID被重复的次数是在RNA seq运行时看到的(因此,这里有7条读取基因"1",2条读取基因"10")。我想用10,000次读取间隔绘制出每读一次识别的基因数,这样如果随机抽取10,000、20,000、30,000等读取,我就可以识别出多少个基因。我用seq()函数做了一个间隔向量,如下所示:
> gaps <- seq(10000, length(allres), by=10000) 但我不知道如何将它应用于我的所有向量并绘制它。任何帮助都是非常感谢的。
发布于 2014-12-22 02:38:19
所以,你可能想要的是这样的:
gaps <- seq(10000, length(allres), by = 10000)
lapply(gaps, function(x){
#This will give you the number of appearances of each value, within
#an gaps[x]-sized sample of allres
aggregated_sample <- table(sample(allres, size = x))
#plotting code for sample goes here. And "x" is the number of reads so
#you can even use it in the title!
#Just remember to include code to save it to disc, if you want to save it to disc.
return(TRUE)
})当然,如果您使用ggplot2进行绘图,您甚至可以将绘图保存为对象,然后返回(绘图)而不是返回(TRUE),然后再进行进一步的调整/调查。
https://stackoverflow.com/questions/27595843
复制相似问题