Mercurial > repos > iuc > snpfreqplot
comparison heatmap_for_variants.R @ 2:dc51db22310c draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/snpfreqplot/ commit d1c54d077cfc0eeb9699719760e668948cb9bbbc"
author | iuc |
---|---|
date | Fri, 18 Dec 2020 23:48:01 +0000 |
parents | e362b3143cde |
children | 3d0adeee3f2b |
comparison
equal
deleted
inserted
replaced
1:e362b3143cde | 2:dc51db22310c |
---|---|
114 ann_final$gene[2:length(ann_final$gene)])) | 114 ann_final$gene[2:length(ann_final$gene)])) |
115 | 115 |
116 # colormanagement | 116 # colormanagement |
117 my_colors <- colorRampPalette(c("grey93", "brown", "black")) #heatmap | 117 my_colors <- colorRampPalette(c("grey93", "brown", "black")) #heatmap |
118 count <- length(unique(ann_final$gene)) #annotations (genes) | 118 count <- length(unique(ann_final$gene)) #annotations (genes) |
119 gene_color <- c(brewer.pal(brewer_color_gene_annotation, n = count)) | 119 gene_color <- rep(c(brewer.pal(brewer_color_gene_annotation, n = count)), length.out = count) |
120 names(gene_color) <- unique(ann_final$gene) | 120 names(gene_color) <- unique(ann_final$gene) |
121 | 121 |
122 # colormanagement annotations (effect) | 122 # colormanagement annotations (effect) |
123 ## Define the full set of colors for each effect that we can encounter | 123 ## Define the full set of colors for each effect that we can encounter |
124 ## This is not bulletproof. The effect names given here were swapped into the | 124 ## This is not bulletproof. The effect names given here were swapped into the |
159 cols <- unlist(str_split(name, " ")) | 159 cols <- unlist(str_split(name, " ")) |
160 ## first 3 are POS REF ALT, and the rest are optional differences | 160 ## first 3 are POS REF ALT, and the rest are optional differences |
161 pos_ref_alt <- cols[1:3] | 161 pos_ref_alt <- cols[1:3] |
162 rest <- "" | 162 rest <- "" |
163 if (length(cols) > 3) { | 163 if (length(cols) > 3) { |
164 rest <- paste0(" :: ", paste(cols[4:length(cols)], sep = " ")) | 164 rest <- paste0(" :: ", paste0(cols[4:length(cols)], collapse = " ")) |
165 } | 165 } |
166 ## Trim the REF or ALT if too long | 166 ## Trim the REF or ALT if too long |
167 if (str_length(pos_ref_alt[2]) > 3) { | 167 if (str_length(pos_ref_alt[2]) > 3) { |
168 pos_ref_alt[2] <- paste0(substring(pos_ref_alt[2], 1, 3), "…") | 168 pos_ref_alt[2] <- paste0(substring(pos_ref_alt[2], 1, 3), "…") |
169 } | 169 } |
173 ## Join required | 173 ## Join required |
174 new_name <- paste0(pos_ref_alt[1], " ", | 174 new_name <- paste0(pos_ref_alt[1], " ", |
175 pos_ref_alt[2], " > ", | 175 pos_ref_alt[2], " > ", |
176 pos_ref_alt[3]) | 176 pos_ref_alt[3]) |
177 ## Join rest | 177 ## Join rest |
178 new_name <- paste0(new_name, " ", paste(rest)) | 178 new_name <- paste0(new_name, " ", rest) |
179 } | 179 } |
180 | 180 |
181 colnames(final) <- sapply(colnames(final), fix_label) | 181 colnames(final) <- sapply(colnames(final), fix_label) |
182 rownames(ann_final) <- sapply(rownames(ann_final), fix_label) | 182 rownames(ann_final) <- sapply(rownames(ann_final), fix_label) |
183 ## sanity test | 183 ## sanity test |