comparison shm_csr.r @ 4:477e95b098fd draft

Uploaded
author davidvanzessen
date Mon, 31 Oct 2016 05:05:26 -0400
parents 275ab5175fd6
children 012a738edf5a
comparison
equal deleted inserted replaced
3:275ab5175fd6 4:477e95b098fd
278 transition2 = merge(transition2, base.order, by.x="id", by.y="base") 278 transition2 = merge(transition2, base.order, by.x="id", by.y="base")
279 279
280 transition2 = merge(transition2, base.order, by.x="variable", by.y="base") 280 transition2 = merge(transition2, base.order, by.x="variable", by.y="base")
281 281
282 transition2[is.na(transition2$value),]$value = 0 282 transition2[is.na(transition2$value),]$value = 0
283 283
284 if(any(transition2$value == 0)){ #having rows of data but a transition table filled with 0 is bad 284 print(transition2)
285
286 if(any(transition2$value != 0)){ #having rows of data but a transition table filled with 0 is bad
285 print("Plotting stacked transition") 287 print("Plotting stacked transition")
286 png(filename=paste("transitions_stacked_", name, ".png", sep="")) 288 png(filename=paste("transitions_stacked_", name, ".png", sep=""))
287 p = ggplot(transition2, aes(factor(reorder(id, order.x)), y=value, fill=factor(reorder(variable, order.y)))) + geom_bar(position="fill", stat="identity", colour="black") #stacked bar 289 p = ggplot(transition2, aes(factor(reorder(id, order.x)), y=value, fill=factor(reorder(variable, order.y)))) + geom_bar(position="fill", stat="identity", colour="black") #stacked bar
288 p = p + xlab("From base") + ylab("To base") + ggtitle("Mutations frequency from base to base") + guides(fill=guide_legend(title=NULL)) 290 p = p + xlab("From base") + ylab("To base") + ggtitle("Mutations frequency from base to base") + guides(fill=guide_legend(title=NULL))
289 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=13, colour="black")) + scale_fill_manual(values=c("A" = "blue4", "G" = "lightblue1", "C" = "olivedrab3", "T" = "olivedrab4")) 291 p = p + theme(panel.background = element_rect(fill = "white", colour="black"), text = element_text(size=13, colour="black")) + scale_fill_manual(values=c("A" = "blue4", "G" = "lightblue1", "C" = "olivedrab3", "T" = "olivedrab4"))