Mercurial > repos > lecorguille > xcms_group
comparison lib.r @ 26:0d05d0458376 draft
"planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 0dcc8bcb1e645574c7f81ec1a43f86be38acd065"
| author | workflow4metabolomics |
|---|---|
| date | Tue, 21 Jul 2020 09:17:27 -0400 |
| parents | a066b8581b97 |
| children | d45a786cbc40 |
comparison
equal
deleted
inserted
replaced
| 25:a066b8581b97 | 26:0d05d0458376 |
|---|---|
| 147 getPlotChromPeakDensity <- function(xdata, param = NULL, mzdigit=4) { | 147 getPlotChromPeakDensity <- function(xdata, param = NULL, mzdigit=4) { |
| 148 pdf(file="plotChromPeakDensity.pdf", width=16, height=12) | 148 pdf(file="plotChromPeakDensity.pdf", width=16, height=12) |
| 149 | 149 |
| 150 par(mfrow = c(3, 1), mar = c(4, 4, 1, 0.5)) | 150 par(mfrow = c(3, 1), mar = c(4, 4, 1, 0.5)) |
| 151 | 151 |
| 152 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1") | 152 if(length(unique(xdata$sample_group))<10){ |
| 153 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1") | |
| 154 }else{ | |
| 155 group_colors <- hcl.colors(length(unique(xdata$sample_group)), palette="Dark 3") | |
| 156 } | |
| 153 names(group_colors) <- unique(xdata$sample_group) | 157 names(group_colors) <- unique(xdata$sample_group) |
| 154 col_per_samp <- as.character(xdata$sample_group) | 158 col_per_samp <- as.character(xdata$sample_group) |
| 155 for(i in 1:length(group_colors)){col_per_samp[col_per_samp==(names(group_colors)[i])]<-group_colors[i]} | 159 for(i in 1:length(group_colors)){col_per_samp[col_per_samp==(names(group_colors)[i])]<-group_colors[i]} |
| 156 | 160 |
| 157 xlim <- c(min(featureDefinitions(xdata)$rtmin), max(featureDefinitions(xdata)$rtmax)) | 161 xlim <- c(min(featureDefinitions(xdata)$rtmin), max(featureDefinitions(xdata)$rtmax)) |
| 170 getPlotAdjustedRtime <- function(xdata) { | 174 getPlotAdjustedRtime <- function(xdata) { |
| 171 | 175 |
| 172 pdf(file="raw_vs_adjusted_rt.pdf", width=16, height=12) | 176 pdf(file="raw_vs_adjusted_rt.pdf", width=16, height=12) |
| 173 | 177 |
| 174 # Color by group | 178 # Color by group |
| 175 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1") | 179 if(length(unique(xdata$sample_group))<10){ |
| 180 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1") | |
| 181 }else{ | |
| 182 group_colors <- hcl.colors(length(unique(xdata$sample_group)), palette="Dark 3") | |
| 183 } | |
| 176 if (length(group_colors) > 1) { | 184 if (length(group_colors) > 1) { |
| 177 names(group_colors) <- unique(xdata$sample_group) | 185 names(group_colors) <- unique(xdata$sample_group) |
| 178 plotAdjustedRtime(xdata, col = group_colors[xdata$sample_group]) | 186 plotAdjustedRtime(xdata, col = group_colors[xdata$sample_group]) |
| 179 legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1) | 187 legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1) |
| 180 } | 188 } |
| 239 main <- paste(type,":",adjusted,"data") | 247 main <- paste(type,":",adjusted,"data") |
| 240 | 248 |
| 241 pdf(pdfname, width=16, height=10) | 249 pdf(pdfname, width=16, height=10) |
| 242 | 250 |
| 243 # Color by group | 251 # Color by group |
| 244 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1") | 252 if(length(unique(xdata$sample_group))<10){ |
| 253 group_colors <- brewer.pal(length(unique(xdata$sample_group)), "Set1") | |
| 254 }else{ | |
| 255 group_colors <- hcl.colors(length(unique(xdata$sample_group)), palette="Dark 3") | |
| 256 } | |
| 245 if (length(group_colors) > 1) { | 257 if (length(group_colors) > 1) { |
| 246 names(group_colors) <- unique(xdata$sample_group) | 258 names(group_colors) <- unique(xdata$sample_group) |
| 247 plot(chrom, col = group_colors[as.factor(chrom$sample_group)], main=main, peakType = "none") | 259 plot(chrom, col = group_colors[as.factor(chrom$sample_group)], main=main, peakType = "none") |
| 248 legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1) | 260 legend("topright", legend=names(group_colors), col=group_colors, cex=0.8, lty=1) |
| 249 } | 261 } |
