# HG changeset patch # User davidvanzessen # Date 1381752761 14400 # Node ID 10cfa5e9186e17ed69e8b1945e83580383daa61e # Parent d27d745d05568372042c9bbaedbff8e7d2dfb362 Uploaded diff -r d27d745d0556 -r 10cfa5e9186e RScript.r --- a/RScript.r Mon Oct 14 07:20:38 2013 -0400 +++ b/RScript.r Mon Oct 14 08:12:41 2013 -0400 @@ -108,13 +108,17 @@ plotVD <- function(dat){ - ggplot() + + img = ggplot() + 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="gold", high="blue", na.value="white") + ggtitle(unique(dat$Sample)) + xlab("D genes") + ylab("V Genes") + + png(paste("HeatmapVD_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Dchain$v.name)), height=100+(15*length(Vchain$v.name))) + print(img) + dev.off() } @@ -126,19 +130,23 @@ completeVD$log = log(completeVD$Length) #completeVD$log[is.na(completeVD$log)] = 0 l = split(completeVD, f=completeVD[,"Sample"]) -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() + + img = ggplot() + 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="gold", high="blue", na.value="white") + ggtitle(unique(dat$Sample)) + xlab("J genes") + ylab("V Genes") + + png(paste("HeatmapVJ_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Jchain$v.name)), height=100+(15*length(Vchain$v.name))) + print(img) + dev.off() } VandJCount = ddply(PRODF, c("Top.V.Gene", "Top.J.Gene", "Sample"), function(x) summary(x$VDJCDR3)) @@ -149,18 +157,20 @@ completeVJ$log = log(completeVJ$Length) #completeVJ$log[is.na(completeVJ$log)] = 0 l = split(completeVJ, f=completeVJ[,"Sample"]) -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() + + img = ggplot() + 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="gold", high="blue", na.value="white") + ggtitle(unique(dat$Sample)) + xlab("J genes") + ylab("D Genes") + + png(paste("HeatmapDJ_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Jchain$v.name)), height=100+(15*length(Dchain$v.name))) + print(img) + dev.off() } DandJCount = ddply(PRODF, c("Top.D.Gene", "Top.J.Gene", "Sample"), function(x) summary(x$VDJCDR3)) @@ -171,9 +181,7 @@ completeDJ$log = log(completeDJ$Length) #completeDJ$log[is.na(completeDJ$log)] = 0 l = split(completeDJ, f=completeDJ[,"Sample"]) -png("HeatmapDJ%d.png", width=150+(15*length(Jchain$v.name)), height=100+(15*length(Dchain$v.name))) lapply(l, FUN=plotDJ) -dev.off() sampleFile <- file("samples.txt") diff -r d27d745d0556 -r 10cfa5e9186e r_wrapper.sh --- a/r_wrapper.sh Mon Oct 14 07:20:38 2013 -0400 +++ b/r_wrapper.sh Mon Oct 14 08:12:41 2013 -0400 @@ -21,11 +21,11 @@ echo "" >> $outputFile echo "

$sample

" >> $outputFile echo "

V-D Heatmap:

V-J Heatmap:

D-J Heatmap:

" >> $outputFile - mv "$outputDir/HeatmapVD$count.png" "$outputDir/VD_$sample.png" + mv "$outputDir/HeatmapVD_$sample.png" "$outputDir/VD_$sample.png" echo "" >> $outputFile - mv "$outputDir/HeatmapVJ$count.png" "$outputDir/VJ_$sample.png" + mv "$outputDir/HeatmapVJ_$sample.png" "$outputDir/VJ_$sample.png" echo "" >> $outputFile - mv "$outputDir/HeatmapDJ$count.png" "$outputDir/DJ_$sample.png" + mv "$outputDir/HeatmapDJ_$sample.png" "$outputDir/DJ_$sample.png" echo "" >> $outputFile count=$((count+1)) done