Mercurial > repos > davidvanzessen > test_plotting_merged
changeset 6:f9a657db7af5 draft
Uploaded
author | davidvanzessen |
---|---|
date | Wed, 16 Oct 2013 04:30:42 -0400 |
parents | 021d293121bb |
children | ba6c6725b12f |
files | RScript.r |
diffstat | 1 files changed, 12 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/RScript.r Mon Oct 14 09:49:29 2013 -0400 +++ b/RScript.r Wed Oct 16 04:30:42 2013 -0400 @@ -33,12 +33,15 @@ PRODF = PROD[ -1] -#unique(PRODF[duplicated(PRODF),]) -#length(row.names(PRODF[duplicated(PRODF),])) +PRODF = unique(PRODF) + +uniqueCount = split(PRODF, f=PRODF[,"Sample"]) -#length(row.names(PRODF)) -PRODF = unique(PRODF) -#length(row.names(PRODF)) +for(i in 1:length(uniqueCount)) { + dat = data.frame(uniqueCount[i]) + sample = paste(unique(dat[,15])) + uniqueCount[sample] = length(dat[,1]) +} PRODFV = ddply(PRODF, c("Sample", "Top.V.Gene"), function(x) summary(x$VDJCDR3)) PRODFV$Length = as.numeric(PRODFV$Length) @@ -100,7 +103,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") +pJ = pJ + xlab("Summary of J gene") + ylab("Frequency") + ggtitle("Relative frequency of J gene usage") png("JPlot.png",width = 800, height = 600) pJ @@ -108,12 +111,11 @@ plotVD <- function(dat){ - #dat = dat[order(dat[,8],dat[,9]),] img = ggplot() + geom_tile(data=dat, aes(x=factor(reorder(Top.D.Gene, chr.orderD)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=log)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + scale_fill_gradient(low="gold", high="blue", na.value="white") + - ggtitle(unique(dat$Sample)) + + ggtitle(paste(unique(dat$Sample), " (N=" , uniqueCount[paste(unique(dat$Sample))] ,")", sep="")) + xlab("D genes") + ylab("V Genes") @@ -139,12 +141,11 @@ plotVJ <- function(dat){ - #dat = dat[order(dat[,8],dat[,9]),] img = ggplot() + geom_tile(data=dat, aes(x=factor(reorder(Top.J.Gene, chr.orderJ)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=log)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + scale_fill_gradient(low="gold", high="blue", na.value="white") + - ggtitle(unique(dat$Sample)) + + ggtitle(paste(unique(dat$Sample), " (N=" , uniqueCount[paste(unique(dat$Sample))] ,")", sep="")) + xlab("J genes") + ylab("V Genes") @@ -166,12 +167,11 @@ lapply(l, FUN=plotVJ) plotDJ <- function(dat){ - #dat = dat[order(dat[,8],dat[,9]),] img = ggplot() + geom_tile(data=dat, aes(x=factor(reorder(Top.J.Gene, chr.orderJ)), y=factor(reorder(Top.D.Gene, chr.orderD)), fill=log)) + theme(axis.text.x = element_text(angle = 90, hjust = 1)) + scale_fill_gradient(low="gold", high="blue", na.value="white") + - ggtitle(unique(dat$Sample)) + + ggtitle(paste(unique(dat$Sample), " (N=" , uniqueCount[paste(unique(dat$Sample))] ,")", sep="")) + xlab("J genes") + ylab("D Genes")