Dan Kortschak
2009-Oct-21 22:08 UTC
[R] drawing a line indicating extent of each factored data series in multipanel lattice xyplot
Hi, Am am plotting aggregated frequency data (extracted from an RDBMS) relating to DNA sequence features for each of the human chromosomes as described in the table chromosomes below (the frequency data is in a table 'hits' that has a value (or not) for each of a set of bins across each chromosome). I would like to mark the extent of the chromosome (according to the length value in chromosome) with a line under the xyplot for each panel (at the moment - not included in the xyplot statement below - I have just added the length in bins to the panel strip, but this is not the best solution for representing the data). I have tried a couple of approaches to this (example below), but have not got anything to work (the 100000 value refers to bin size). Can anyone suggest an approach to accomplish this? An additional though less significant question is how I can get the panels to be in the order of the chromosomes as listed in the chromosomes table rather than alphabetical order of their names. thanks Dan> chromosomeschromosome refSeq name length 1 0 NC_000001.9 Homo sapiens chromosome 1 247249719 2 1 NC_000002.10 Homo sapiens chromosome 2 242951149 3 2 NC_000003.10 Homo sapiens chromosome 3 199501827 4 3 NC_000004.10 Homo sapiens chromosome 4 191273063 5 4 NC_000005.8 Homo sapiens chromosome 5 180857866 6 5 NC_000006.10 Homo sapiens chromosome 6 170899992 7 6 NC_000007.12 Homo sapiens chromosome 7 158821424 8 7 NC_000008.9 Homo sapiens chromosome 8 146274826 9 8 NC_000009.10 Homo sapiens chromosome 9 140273252 10 9 NC_000010.9 Homo sapiens chromosome 10 135374737 11 10 NC_000011.8 Homo sapiens chromosome 11 134452384 12 11 NC_000012.10 Homo sapiens chromosome 12 132349534 13 12 NC_000013.9 Homo sapiens chromosome 13 114142980 14 13 NC_000014.7 Homo sapiens chromosome 14 106368585 15 14 NC_000015.8 Homo sapiens chromosome 15 100338915 16 15 NC_000016.8 Homo sapiens chromosome 16 88827254 17 16 NC_000017.9 Homo sapiens chromosome 17 78774742 18 17 NC_000018.8 Homo sapiens chromosome 18 76117153 19 18 NC_000019.8 Homo sapiens chromosome 19 63811651 20 19 NC_000020.9 Homo sapiens chromosome 20 62435964 21 20 NC_000021.7 Homo sapiens chromosome 21 46944323 22 21 NC_000022.9 Homo sapiens chromosome 22 49691432 23 22 NC_001807.4 Homo sapiens mitochondrion 16571 24 23 NC_000023.9 Homo sapiens chromosome X 154913754 25 24 NC_000024.8 Homo sapiens chromosome Y 57772954 xyplot(hits~bin|chromosomes$name[chromosome+1], data=hits, horizontal=FALSE, origin=0, lab=c(3,10),pch=20,cex=0.01, layout=c(1,5,5), strip=strip.custom(style=3, bg="grey90",par.strip.text=list(cex=0.5)), as.table=TRUE, panel=function(x,y,...,length=chromosomes$length[chromosome+1]) {panel.xyplot(x,y,...); panel.lines(0,-100,length/100000,-100)} )