delimit sections in a lattice plot

喜你入骨 提交于 2019-12-12 01:23:55

问题


Consider a slice of a larger data.frame:

dput(head(alele_freq_dev))
structure(list(chr = c("1A", "1A", "1A", "1A", "1A", "1A"), locus = 
c(1145442L, 1158042L, 1158055L, 1229616L, 1236254L, 1238114L), Trial = 
structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("ES1-5", "ES6-13", "ES14- 
26", "ES27-38", "SA1-13", "SA14-25"), class = "factor"), MAF = 
c(0.0780052257586973, 0.201305225758697, 
-0.101594774241303,-0.105094774241303, 0.0710052257586973, 
-0.101594774241303)), row.names = c(NA, 6L), class = "data.frame")

The df looks like that :

chr   locus Trial         MAF
1A 1145442 ES1-5  0.07800523
1A 1158042 ES1-5  0.20130523
1A 1158055 ES1-5 -0.10159477
1A 1229616 ES1-5 -0.10509477
1A 1236254 ES1-5  0.07100523
1A 1238114 ES1-5 -0.10159477

And the following lattice plot code:

   xyplot(MAF ~ locus | chr, data = alele_freq_dev,
   layout = c(1, 3),
   as.table=T,
   main='MAF per Chromosome',
   grid=T,
   group = Trial,
   type = c('p'),
   cex = 0.1,
   par.settings = Mytheme,
   auto.key = list(title='Trial',space='top',columns=4,lines=F,points=T)) 

I would like to highlight the areas on this picture within a certain range of the x-axis (locus), any form of highlighting is appreciated, for instance a shaded area. The ranges are chr(chromosome) dependent. The following data frame sketches how the ranges should be assigned:

structure(list(chr = c("1A", "1B", "1D", "2A", "2B", "2D"), initial = 
c(210200000L, 237700000L, 166200000L, 326300000L, 344400000L, 264400000L), 
end = c(215800000L, 243500000L, 173800000L, 327000000L, 351300000L, 
272500000L)), row.names = c(NA, 6L), class = "data.frame")

The data frame looks like this :

chr   initial       end
1A 210200000 215800000
1B 237700000 243500000
1D 166200000 173800000
2A 326300000 327000000
2B 344400000 351300000
2D 264400000 272500000

来源:https://stackoverflow.com/questions/53730927/delimit-sections-in-a-lattice-plot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!