I am attempting to use R to plot copy-number along chromosomes via read depth. I have already calculated the normalized read counts per 75kb bins, and the relative integer copy number, so plotting the data in R is where I am getting hung up.
My data (named "75kb_run") looks like this:
Chrom Strt End Sample1 Sample2 Sample3 Sample4 Sample5 Sample6
chr1 1 75000 2.133 1.979 2.005 2.154 2.076 2.112
chr1 75001 150000 1.989 2.075 2.089 2.052 2.019 1.965
chr1 150001 225000 2.234 1.936 2.181 2.108 2.242 2.158
chr1 225001 300000 2.453 1.651 2.235 1.932 2.472 2.524
chr1 300001 375000 2.19 2.001 2.106 2.132 1.98 2.174
chr2 1 75000 1.941 2.243 1.906 2.012 2.154 1.969
chr2 75001 150000 1.899 2.316 1.959 2.053 1.995 1.887
chr2 150001 225000 1.92 2.104 1.942 2.035 2.191 1.719
chr2 225001 300000 2.25 1.921 1.99 2.213 2.237 1.665
chr2 300001 375000 1.631 2.595 1.816 1.904 1.75 2.131
chr2 375001 450000 2.068 2.372 2.134 1.959 1.899 1.684
chr2 450001 525000 1.933 2.291 2.026 2.001 1.966 1.822
chr3 1 75000 2.222 1.225 1.753 0.657 2.844 2.719
chr3 75001 150000 2.403 1.44 2.123 1.514 2.574 2.63
chr3 150001 225000 2.244 1.62 2.401 2.025 2.095 2.324
chr3 225001 300000 2.042 1.261 2.009 2.045 2.161 1.901
chr3 300001 375000 2.049 1.132 2.016 2.125 2.291 2.065
chr3 375001 450000 2.184 1.66 2.013 2.404 1.895 2.695
chr3 450001 525000 2.742 0.955 1.481 2.296 2.342 2.003
Using R, I can make individual scatter plots for each chromosome for each Sample.
chr2=`75kb_run`[grep("^chr2$", `75kb_run`$Chrom),]
Sample1_chr2=ggplot(`chr2`, aes(x=Strt, y=`chr2`$Sample1))
Sample1_chr2+
geom_point() + scale_y_continuous(limits=c(0,4))
However, I would like to plot all of the chromosomes per sample at once, looking something like Figure 2 in this paper.
I think I don't quite understand how to arrange the Chrom column as a factor. Any help would be appreciated.
Bonus points if anyone could provide an example script that loops through all of the Samples given a list ( sampleList=c("Sample1"," Sample2"," Sample3") ).
Thank you, Mike
hi . I want to plot my CNV file generated from cn.Mops i want to plot all snp chromosome wise per sample any idea? my file look like this:
Please post as a new question, not as a comment