totalReads=10000
mappedReads=8000
mappedTargetReads=6000
unmappedReads=totalReads-mappedReads
offtargetmappedReads=mappedReads-mappedTargetReads
data<-c(mappedReads,unmappedReads,mappedTargetReads,offtargetmappedReads)
round(data[1]/totalReads*100)->a
round(data[2]/totalReads*100)->b
round(data[3]/mappedReads*100)->c
round(data[4]/mappedReads*100)->d
pct<-c(a,b,c,d)
labels<-c("MappedReads","UnmappedReads","On-exon","Off-exon")
labels<-paste(labels,pct)
labels<-paste(labels,"%", sep="")
pie(c(mappedReads,unmappedReads,mappedTargetReads,offtargetmappedReads),labels=labels)

它基本上独立地绘制了所有四个切片。但是这里 mappedTargetReadsofftargetmappedReads 是根据映射读取计算的,因此,我想分割 mappedReads 切片并在 mappedTargetReads 中表示 offtargetmappedReadsmappedReads

或者是否可以在单个 Rplot 中绘制两个彼此相邻的不同饼图?

最佳答案

这将生成一个带有两个饼图的图:

par(mfrow = c(1,2))
pie(c(mappedReads,unmappedReads),labels=labels[1:2], main = "Global")
pie(c(mappedTargetReads,offtargetmappedReads),labels=labels[3:4],
    main = "MappedReads")

关于r - 在 R 中绘制饼图,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13103416/

10-12 18:03