Mercurial > repos > davidvanzessen > plotting_merged
comparison RScript.r @ 37:16fe6233f90e draft
Uploaded
author | davidvanzessen |
---|---|
date | Fri, 08 Nov 2013 06:54:21 -0500 |
parents | b3c97b26db60 |
children | 6e490e056fc4 |
comparison
equal
deleted
inserted
replaced
36:b3c97b26db60 | 37:16fe6233f90e |
---|---|
113 | 113 |
114 plotVD <- function(dat){ | 114 plotVD <- function(dat){ |
115 img = ggplot() + | 115 img = ggplot() + |
116 geom_tile(data=dat, aes(x=factor(reorder(Top.D.Gene, chr.orderD)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=log)) + | 116 geom_tile(data=dat, aes(x=factor(reorder(Top.D.Gene, chr.orderD)), y=factor(reorder(Top.V.Gene, chr.orderV)), fill=log)) + |
117 theme(axis.text.x = element_text(angle = 90, hjust = 1)) + | 117 theme(axis.text.x = element_text(angle = 90, hjust = 1)) + |
118 scale_fill_gradient(low="gold", high="blue", na.value="white", limits=c(0, maxVD)) + | 118 scale_fill_gradient(low="gold", high="blue", na.value="white") + |
119 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat[!is.na(dat[,4]),][4]) ,")", sep="")) + | 119 ggtitle(paste(unique(dat$Sample), " (N=" , sum(dat[!is.na(dat[,4]),][4]) ,")", sep="")) + |
120 xlab("D genes") + | 120 xlab("D genes") + |
121 ylab("V Genes") | 121 ylab("V Genes") |
122 | 122 |
123 png(paste("HeatmapVD_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Dchain$v.name)), height=100+(15*length(Vchain$v.name))) | 123 png(paste("HeatmapVD_", unique(dat[3])[1,1] , ".png", sep=""), width=150+(15*length(Dchain$v.name)), height=100+(15*length(Vchain$v.name))) |
124 print(img) | 124 print(img) |
125 dev.off() | 125 dev.off() |
126 } | 126 } |
127 | 127 |
128 VandDCount = data.frame(data.table(PRODF)[, list(Length=.N), by=c("Top.V.Gene", "Top.D.Gene", "Sample")]) | 128 VandDCount = data.frame(data.table(PRODF)[, list(Length=.N), by=c("Top.V.Gene", "Top.D.Gene", "Sample")]) |
129 | |
130 | |
131 | |
132 | |
133 cartegianProductVD = expand.grid(Top.V.Gene = Vchain$v.name, Top.D.Gene = Dchain$v.name, Sample = unique(test$Sample)) | 129 cartegianProductVD = expand.grid(Top.V.Gene = Vchain$v.name, Top.D.Gene = Dchain$v.name, Sample = unique(test$Sample)) |
134 | 130 |
135 completeVD = merge(VandDCount, cartegianProductVD, all.y=TRUE) | 131 completeVD = merge(VandDCount, cartegianProductVD, all.y=TRUE) |
136 completeVD$Length = as.numeric(completeVD$Length) | 132 completeVD$Length = as.numeric(completeVD$Length) |
137 completeVD$log = log(completeVD$Length) | 133 completeVD$log = log(completeVD$Length) |
138 maxVD = max(subset(completeVD, !is.na(completeVD$log), "log")) | |
139 completeVD = merge(completeVD, Vchain, by.x="Top.V.Gene", by.y="v.name", all.x=TRUE) | 134 completeVD = merge(completeVD, Vchain, by.x="Top.V.Gene", by.y="v.name", all.x=TRUE) |
140 completeVD = merge(completeVD, Dchain, by.x="Top.D.Gene", by.y="v.name", all.x=TRUE) | 135 completeVD = merge(completeVD, Dchain, by.x="Top.D.Gene", by.y="v.name", all.x=TRUE) |
141 #completeVD$log[is.na(completeVD$log)] = 0 | 136 #completeVD$log[is.na(completeVD$log)] = 0 |
142 l = split(completeVD, f=completeVD[,"Sample"]) | 137 l = split(completeVD, f=completeVD[,"Sample"]) |
143 | 138 |