comparison mutational_patterns.R @ 10:59c0e2a7965c draft

"planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/mutational_patterns commit 533394bd219d56cde7fb9721803e8aed8fd5a25d"
author artbio
date Mon, 19 Oct 2020 23:34:58 +0000
parents 4ff3c984523b
children 7995a949189f
comparison
equal deleted inserted replaced
9:4ff3c984523b 10:59c0e2a7965c
314 worklist[[i]] <- worklist[[i]][order(worklist[[i]][ ,"sum"], decreasing = T), ] 314 worklist[[i]] <- worklist[[i]][order(worklist[[i]][ ,"sum"], decreasing = T), ]
315 worklist[[i]] <- worklist[[i]][1:opt$signum,] 315 worklist[[i]] <- worklist[[i]][1:opt$signum,]
316 worklist[[i]] <- worklist[[i]][ , -length(as.data.frame(worklist[[i]]))] 316 worklist[[i]] <- worklist[[i]][ , -length(as.data.frame(worklist[[i]]))]
317 } 317 }
318 worklist <- as.data.frame(melt(worklist)) 318 worklist <- as.data.frame(melt(worklist))
319 worklist[,2] <- paste0(worklist[,2], " - ", worklist[,4]) 319 worklist[,2] <- paste0(worklist[,4], " - ", worklist[,2])
320 head(worklist) 320 head(worklist)
321 } 321 }
322 322
323 colnames(worklist) <- c("signature", "sample", "value", "level") 323 colnames(worklist) <- c("signature", "sample", "value", "level")
324 worklist <- as.data.frame(worklist %>% group_by(sample) %>% mutate(value=value/sum(value)*100)) 324 worklist <- as.data.frame(worklist %>% group_by(sample) %>% mutate(value=value/sum(value)*100))
326 worklist$label <- factor(worklist$signature) 326 worklist$label <- factor(worklist$signature)
327 worklist$signature <- factor(worklist$signature) 327 worklist$signature <- factor(worklist$signature)
328 p7 <- ggplot(worklist, aes(x="", y=value, group=signature, fill=signature)) + 328 p7 <- ggplot(worklist, aes(x="", y=value, group=signature, fill=signature)) +
329 geom_bar(width = 1, stat = "identity") + 329 geom_bar(width = 1, stat = "identity") +
330 geom_text(aes(label = label), position = position_stack(vjust = 0.5), color="black", size=3) + 330 geom_text(aes(label = label), position = position_stack(vjust = 0.5), color="black", size=3) +
331 coord_polar("y", start=0) + facet_wrap(~ sample) + 331 coord_polar("y", start=0) + facet_wrap(.~sample) +
332 labs(x="", y="Samples", fill = cosmic_tag) + 332 labs(x="", y="Samples", fill = cosmic_tag) +
333 scale_fill_manual(name = paste0(opt$signum, " most contributing\nsignatures\n(in each label/tissue)"), 333 scale_fill_manual(name = paste0(opt$signum, " most contributing\nsignatures\n(in each label/tissue)"),
334 values = cosmic_colors[as.numeric(levels(factor(worklist$label)))]) + 334 values = cosmic_colors[as.numeric(levels(factor(worklist$label)))]) +
335 theme(axis.text = element_blank(), 335 theme(axis.text = element_blank(),
336 axis.ticks = element_blank(), 336 axis.ticks = element_blank(),