Mercurial > repos > lecorguille > xcms_summary
comparison lib.r @ 27:bed23aa27b4b draft
"planemo upload for repository https://github.com/workflow4metabolomics/xcms commit 50478425b4773ebcb393c0e31f1e622b7406dcbb"
| author | workflow4metabolomics |
|---|---|
| date | Thu, 24 Sep 2020 08:09:02 +0000 |
| parents | db6549f27ad1 |
| children | 018a9771de28 |
comparison
equal
deleted
inserted
replaced
| 26:db6549f27ad1 | 27:bed23aa27b4b |
|---|---|
| 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[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 } |
| 250 | 262 |
| 251 # Color by sample | 263 # Color by sample |
| 252 plot(chrom, col = rainbow(length(xdata@phenoData@data$sample_name)), main=main, peakType = "none") | 264 plot(chrom, col = rainbow(length(xdata@phenoData@data$sample_name)), main=main, peakType = "none") |
