Mercurial > repos > iuc > volcanoplot
comparison test-data/out.rscript @ 11:5e08a1e22dbc draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/volcanoplot commit 8031afb306afd728f682d754e9270dc22c64c61c
author | iuc |
---|---|
date | Wed, 29 Jan 2025 10:37:54 +0000 |
parents | 99ace6c1ff57 |
children |
comparison
equal
deleted
inserted
replaced
10:99ace6c1ff57 | 11:5e08a1e22dbc |
---|---|
18 }) | 18 }) |
19 | 19 |
20 | 20 |
21 # Import data ------------------------------------------------------------ | 21 # Import data ------------------------------------------------------------ |
22 | 22 |
23 results <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmprh4qip75/files/d/2/2/dataset_d2255b46-f0f6-4900-8b9e-bd352e34f303.dat', header = TRUE) | 23 results <- read.delim('/tmp/tmpl4o1f_bf/files/5/2/5/dataset_52538741-d085-42da-817b-263bd4f7cf98.dat', header = TRUE) |
24 | 24 |
25 | 25 |
26 # Format data ------------------------------------------------------------ | 26 # Format data ------------------------------------------------------------ |
27 | 27 |
28 # Create columns from the column numbers specified | 28 # Create columns from the column numbers specified and use the existing category_symbol column for shapes |
29 results <- results %>% mutate(fdr = .[[4]], | 29 results <- results %>% mutate( |
30 pvalue = .[[3]], | 30 fdr = .[[4]], |
31 logfc = .[[2]], | 31 pvalue = .[[3]], |
32 labels = .[[1]]) | 32 logfc = .[[2]], |
33 labels = .[[1]], | |
34 ) | |
35 | |
36 # Check if shape_col is provided | |
33 | 37 |
34 # Get names for legend | 38 # Get names for legend |
35 down <- unlist(strsplit('Down,Not Sig,Up', split = ","))[1] | 39 down <- unlist(strsplit('Down,Not Sig,Up', split = ","))[1] |
36 notsig <- unlist(strsplit('Down,Not Sig,Up', split = ","))[2] | 40 notsig <- unlist(strsplit('Down,Not Sig,Up', split = ","))[2] |
37 up <- unlist(strsplit('Down,Not Sig,Up', split = ","))[3] | 41 up <- unlist(strsplit('Down,Not Sig,Up', split = ","))[3] |
47 | 51 |
48 | 52 |
49 # Specify genes to label -------------------------------------------------- | 53 # Specify genes to label -------------------------------------------------- |
50 | 54 |
51 # Import file with genes of interest | 55 # Import file with genes of interest |
52 labelfile <- read.delim('/private/var/folders/zn/m_qvr9zd7tq0wdtsbq255f8xypj_zg/T/tmprh4qip75/files/5/e/5/dataset_5e5b8fb0-bf65-438e-9b5b-03a540d9aa5d.dat', header = TRUE) | 56 labelfile <- read.delim('/tmp/tmpl4o1f_bf/files/5/d/4/dataset_5d401b02-f6af-4ed9-b853-992fd4a4d044.dat', header = TRUE) |
53 | 57 |
54 # Label the genes of interest in results table | 58 # Label the genes of interest in results table |
55 results <- mutate(results, labels = ifelse(labels %in% labelfile[, 1], labels, "")) | 59 results <- mutate(results, labels = ifelse(labels %in% labelfile[, 1], labels, "")) |
56 | 60 |
57 | 61 |
59 # Create plot ------------------------------------------------------------- | 63 # Create plot ------------------------------------------------------------- |
60 | 64 |
61 # Open file to save plot as PDF | 65 # Open file to save plot as PDF |
62 pdf("volcano_plot.pdf") | 66 pdf("volcano_plot.pdf") |
63 | 67 |
64 # Set up base plot | 68 # Set up base plot with faceting by category_symbol instead of shapes |
65 p <- ggplot(data = results, aes(x = logfc, y = -log10(pvalue))) + | 69 p <- ggplot(data = results, aes(x = logfc, y = -log10(pvalue))) + |
66 geom_point(aes(colour = sig)) + | |
67 scale_color_manual(values = colours) + | 70 scale_color_manual(values = colours) + |
68 theme(panel.grid.major = element_blank(), | 71 theme(panel.grid.major = element_blank(), |
69 panel.grid.minor = element_blank(), | 72 panel.grid.minor = element_blank(), |
70 panel.background = element_blank(), | 73 panel.background = element_blank(), |
71 axis.line = element_line(colour = "black"), | 74 axis.line = element_line(colour = "black"), |
72 legend.key = element_blank()) | 75 legend.key = element_blank()) |
76 | |
77 # Conditional logic to use either shape or facet based on user selection | |
78 p <- p + geom_point(aes(colour = sig)) #only add color | |
73 | 79 |
74 # Add gene labels | 80 # Add gene labels |
75 p <- p + geom_text_repel(data = filter(results, labels != ""), aes(label = labels), | 81 p <- p + geom_text_repel(data = filter(results, labels != ""), aes(label = labels), |
76 min.segment.length = 0, | 82 min.segment.length = 0, |
77 max.overlaps = Inf, | 83 max.overlaps = Inf, |