comparison RScript.r @ 39:a9ad03d52680 draft

Uploaded
author davidvanzessen
date Fri, 15 Nov 2013 04:00:13 -0500
parents 6e490e056fc4
children af2834de221c
comparison
equal deleted inserted replaced
38:6e490e056fc4 39:a9ad03d52680
24 } 24 }
25 library(data.table) 25 library(data.table)
26 26
27 27
28 test = read.table(inFile, sep="\t", header=TRUE, fill=T) 28 test = read.table(inFile, sep="\t", header=TRUE, fill=T)
29
30 test = test[test$Sample != "",]
29 31
30 test$Top.V.Gene = gsub("[*]([0-9]+)", "", test$Top.V.Gene) 32 test$Top.V.Gene = gsub("[*]([0-9]+)", "", test$Top.V.Gene)
31 test$Top.D.Gene = gsub("[*]([0-9]+)", "", test$Top.D.Gene) 33 test$Top.D.Gene = gsub("[*]([0-9]+)", "", test$Top.D.Gene)
32 test$Top.J.Gene = gsub("[*]([0-9]+)", "", test$Top.J.Gene) 34 test$Top.J.Gene = gsub("[*]([0-9]+)", "", test$Top.J.Gene)
33 35
114 revDchain = Dchain 116 revDchain = Dchain
115 revVchain$chr.orderV = rev(revVchain$chr.orderV) 117 revVchain$chr.orderV = rev(revVchain$chr.orderV)
116 revDchain$chr.orderD = rev(revDchain$chr.orderD) 118 revDchain$chr.orderD = rev(revDchain$chr.orderD)
117 119
118 plotVD <- function(dat){ 120 plotVD <- function(dat){
121 if(length(dat[,1]) == 0){
122 return()
123 }
119 img = ggplot() + 124 img = ggplot() +
120 geom_tile(data=dat, aes(x=factor(reorder(Top.D.Gene, chr.orderD)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=relLength)) + 125 geom_tile(data=dat, aes(x=factor(reorder(Top.D.Gene, chr.orderD)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=relLength)) +
121 theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 126 theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
122 scale_fill_gradient(low="gold", high="blue", na.value="white") + 127 scale_fill_gradient(low="gold", high="blue", na.value="white") +
123 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat$Length, na.rm=T) ,")", sep="")) + 128 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat$Length, na.rm=T) ,")", sep="")) +
146 lapply(VDList, FUN=plotVD) 151 lapply(VDList, FUN=plotVD)
147 152
148 153
149 154
150 plotVJ <- function(dat){ 155 plotVJ <- function(dat){
156 if(length(dat[,1]) == 0){
157 return()
158 }
151 img = ggplot() + 159 img = ggplot() +
152 geom_tile(data=dat, aes(x=factor(reorder(Top.J.Gene, chr.orderJ)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=relLength)) + 160 geom_tile(data=dat, aes(x=factor(reorder(Top.J.Gene, chr.orderJ)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=relLength)) +
153 theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 161 theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
154 scale_fill_gradient(low="gold", high="blue", na.value="white") + 162 scale_fill_gradient(low="gold", high="blue", na.value="white") +
155 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat$Length, na.rm=T) ,")", sep="")) + 163 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat$Length, na.rm=T) ,")", sep="")) +
175 completeVJ = merge(completeVJ, Jchain, by.x="Top.J.Gene", by.y="v.name", all.x=TRUE) 183 completeVJ = merge(completeVJ, Jchain, by.x="Top.J.Gene", by.y="v.name", all.x=TRUE)
176 VJList = split(completeVJ, f=completeVJ[,"Sample"]) 184 VJList = split(completeVJ, f=completeVJ[,"Sample"])
177 lapply(VJList, FUN=plotVJ) 185 lapply(VJList, FUN=plotVJ)
178 186
179 plotDJ <- function(dat){ 187 plotDJ <- function(dat){
188 if(length(dat[,1]) == 0){
189 return()
190 }
180 img = ggplot() + 191 img = ggplot() +
181 geom_tile(data=dat, aes(x=factor(reorder(Top.J.Gene, chr.orderJ)), y=factor(reorder(Top.D.Gene, chr.orderD)), fill=relLength)) + 192 geom_tile(data=dat, aes(x=factor(reorder(Top.J.Gene, chr.orderJ)), y=factor(reorder(Top.D.Gene, chr.orderD)), fill=relLength)) +
182 theme(axis.text.x = element_text(angle = 90, hjust = 1)) + 193 theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
183 scale_fill_gradient(low="gold", high="blue", na.value="white") + 194 scale_fill_gradient(low="gold", high="blue", na.value="white") +
184 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat$Length, na.rm=T) ,")", sep="")) + 195 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat$Length, na.rm=T) ,")", sep="")) +