[R] questions related to ploting in R
Adaikalavan Ramasamy
ramasamy at cancer.org.uk
Wed Mar 2 15:21:13 CET 2005
You have to decided whether you want one single plot or 23 plots (one
for each chromosome). Since I suspect that, say, copy_num at the end of
Chromosome 1 and the copy_num at the start of Chromosome 2 are not
related (like time series data) and would suggest 23 plots instead.
# simulate data #
df <- data.frame( Chromosome=rep(1:23, each=10),
location=round(runif(230, max=1000000)),
copy_num=runif(230, max=10) )
head(df)
Chromosome location copy_num
1 1 289588 7.3537879
2 1 267081 8.3605345
3 1 926470 0.1270541
4 1 214679 7.1798719
5 1 388366 4.2847290
6 1 332667 7.7888741
...
library(lattice)
xyplot( copy_num ~ location | Chromosome, data=df )
If you want it as one big plot, then you will need to somehow adjust the
location variable. I would suggest you think about putting the
chromosomes end to end. If you add the cumulative length of each
chromosome to the location to all the variables within a chromosome,
then you will get unique mapping for location.
For example, if Chromosome 1 was 1,000,000 bases long and Chromosome 2
was 800,000 bases long, then a gene in location 500 of Chromosome 3
would actually be in position 1,800,500 (= 1,000,000 + 800,000 + 500) in
the overall map. Then you can simple plot the copy_num vs the new
location variable.
You might want to also check BioConductor packages if they have anything
more specific to your needs.
Regards, Adai
On Fri, 2004-08-06 at 16:03 -0400, Li, Aiguo (NIH/NCI) wrote:
> Dear all.
>
> I need to draw a scatter plot of 23 chromosome copy numbers (y axes) against
> chromosome and physical location within each chromosome in one plot. The
> data matrix looks as below:
>
> chr location copy_num
> 1 118345 1.320118
> 1 3776202 1.133879
> 1 4798845 0.989997
> 1 5350951 1.100967
> . more data here
> .
> .
> 2 118345 2.459119
> 2 157739 1.915919
> 2 1530065 1.924372
> 2 1530235 3.138177
> .
> .
> .
> more data here
> 23 118345 2.454111
> 23 5142838 1.719263
> 23 5163858 1.228840
>
> The x axes of the plot should have chromosome label from 1 to 23 and
> physical location within each chromosome label. The physical location
> values start from each chromosome (not necessaryly same value). That means
> that x axes will have label (tick) for chromosome 1, within chromosome 1
> there are physical location from whatever value to the largest physical
> location value for chromosome 1, then chromosome 2 label, within chromosome
> 2 label physical location increase from whatever value to the largest
> physical location value for chromosome 2...... till chromosome 23.
>
> Is it possible to draw this type of plot in R? and How to draw it?
>
> Thanks in advance
>
> Aiguo Li, Ph.D.
> Bioinformatician & Molecular biologist
> NCI/NIH
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
More information about the R-help
mailing list