Mercurial > repos > davidvanzessen > test_plotting_merged
changeset 2:aac19ac7cb21 draft
Uploaded
author | davidvanzessen |
---|---|
date | Fri, 11 Oct 2013 09:11:03 -0400 |
parents | c43c63f4ef80 |
children | d27d745d0556 |
files | RScript.r |
diffstat | 1 files changed, 22 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/RScript.r Wed Oct 09 07:29:08 2013 -0400 +++ b/RScript.r Fri Oct 11 09:11:03 2013 -0400 @@ -9,7 +9,7 @@ if (!require("gridExtra")) { install.packages("gridExtra", repos="http://cran.xl-mirror.nl/") } -library (gridExtra) +library(gridExtra) if (!require("ggplot2")) { install.packages("ggplot2", repos="http://cran.xl-mirror.nl/") } @@ -84,6 +84,7 @@ pV = ggplot(PRODFV) pV = pV + geom_bar( aes( x=factor(reorder(Top.V.Gene, chr.orderV)), y=relFreq, fill=Sample), stat='identity', position="dodge") + theme(axis.text.x = element_text(angle = 90, hjust = 1)) +pV = pV + xlab("Summary of V gene") + ylab("Frequency") + ggtitle("Relative frequency of V gene usage") png("VPlot.png",width = 1280, height = 720) pV @@ -91,6 +92,7 @@ pD = ggplot(PRODFD) pD = pD + geom_bar( aes( x=factor(reorder(Top.D.Gene, chr.orderD)), y=relFreq, fill=Sample), stat='identity', position="dodge") + theme(axis.text.x = element_text(angle = 90, hjust = 1)) +pD = pD + xlab("Summary of D gene") + ylab("Frequency") + ggtitle("Relative frequency of D gene usage") png("DPlot.png",width = 800, height = 600) pD @@ -98,6 +100,7 @@ pJ = ggplot(PRODFJ) pJ = pJ + geom_bar( aes( x=factor(reorder(Top.J.Gene, chr.orderJ)), y=relFreq, fill=Sample), stat='identity', position="dodge") + theme(axis.text.x = element_text(angle = 90, hjust = 1)) +pJ = pJ + xlab("Summary of J gene") + ylab("Frequency") + ggtitle("Relative frequency of D gene usage") png("JPlot.png",width = 800, height = 600) pJ @@ -106,10 +109,12 @@ plotVD <- function(dat){ ggplot() + - geom_tile(data=dat, aes(x=factor(Top.V.Gene), y=factor(Top.D.Gene), fill=log)) + + geom_tile(data=dat, aes(x=factor(Top.D.Gene), y=factor(Top.V.Gene), fill=log)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + - scale_fill_gradient(low="white", high="red") + - ggtitle(unique(dat$Sample)) + scale_fill_gradient(low="gold", high="blue") + + ggtitle(unique(dat$Sample)) + + xlab("D genes") + + ylab("V Genes") } @@ -121,17 +126,19 @@ completeVD$log = log(completeVD$Length) completeVD$log[is.na(completeVD$log)] = 0 l = split(completeVD, f=completeVD[,"Sample"]) -png("HeatmapVD%d.png", width=100+(15*length(Vchain$v.name)), height=100+(15*length(Dchain$v.name))) +png("HeatmapVD%d.png", width=150+(15*length(Dchain$v.name)), height=100+(15*length(Vchain$v.name))) lapply(l, FUN=plotVD) dev.off() plotVJ <- function(dat){ ggplot() + - geom_tile(data=dat, aes(x=factor(Top.V.Gene), y=factor(Top.J.Gene), fill=log)) + + geom_tile(data=dat, aes(x=factor(Top.J.Gene), y=factor(Top.V.Gene), fill=log)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + - scale_fill_gradient(low="white", high="red") + - ggtitle(unique(dat$Sample)) + scale_fill_gradient(low="gold", high="blue") + + ggtitle(unique(dat$Sample)) + + xlab("J genes") + + ylab("V Genes") } VandJCount = ddply(PRODF, c("Top.V.Gene", "Top.J.Gene", "Sample"), function(x) summary(x$VDJCDR3)) @@ -142,16 +149,18 @@ completeVJ$log = log(completeVJ$Length) completeVJ$log[is.na(completeVJ$log)] = 0 l = split(completeVJ, f=completeVJ[,"Sample"]) -png("HeatmapVJ%d.png", width=100+(15*length(Vchain$v.name)), height=100+(15*length(Jchain$v.name))) +png("HeatmapVJ%d.png", width=150+(15*length(Jchain$v.name)), height=100+(15*length(Vchain$v.name))) lapply(l, FUN=plotVJ) dev.off() plotDJ <- function(dat){ ggplot() + - geom_tile(data=dat, aes(x=factor(Top.D.Gene), y=factor(Top.J.Gene), fill=log)) + + geom_tile(data=dat, aes(x=factor(Top.J.Gene), y=factor(Top.D.Gene), fill=log)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + - scale_fill_gradient(low="white", high="red") + - ggtitle(unique(dat$Sample)) + scale_fill_gradient(low="gold", high="blue") + + ggtitle(unique(dat$Sample)) + + xlab("J genes") + + ylab("D Genes") } DandJCount = ddply(PRODF, c("Top.D.Gene", "Top.J.Gene", "Sample"), function(x) summary(x$VDJCDR3)) @@ -162,7 +171,7 @@ completeDJ$log = log(completeDJ$Length) completeDJ$log[is.na(completeDJ$log)] = 0 l = split(completeDJ, f=completeDJ[,"Sample"]) -png("HeatmapDJ%d.png", width=100+(15*length(Dchain$v.name)), height=100+(15*length(Jchain$v.name))) +png("HeatmapDJ%d.png", width=150+(15*length(Jchain$v.name)), height=100+(15*length(Dchain$v.name))) lapply(l, FUN=plotDJ) dev.off()