comparison test-data/out.rscript @ 10:99ace6c1ff57 draft default tip

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