comparison anticipated_purity_dims.R @ 13:c7dd031d02b9 draft

planemo upload for repository https://github.com/computational-metabolomics/mspurity-galaxy commit e6935a8c6a3da23f47a753ab5a8159fa9d165535
author tomnl
date Fri, 11 May 2018 05:57:56 -0400
parents e9026031dab3
children
comparison
equal deleted inserted replaced
12:291c9c7f63da 13:c7dd031d02b9
27 27
28 if (is.null(opt$dimspy)){ 28 if (is.null(opt$dimspy)){
29 29
30 df <- read.table(opt$peaks_file, header = TRUE, sep='\t') 30 df <- read.table(opt$peaks_file, header = TRUE, sep='\t')
31 filename = NA 31 filename = NA
32 mzml_file <- opt$mzML_file
32 }else{ 33 }else{
33 indf <- read.table(opt$peaks_file, 34 indf <- read.table(opt$peaks_file,
34 header = TRUE, sep='\t', stringsAsFactors = FALSE) 35 header = TRUE, sep='\t', stringsAsFactors = FALSE)
35 36
36 filename = colnames(indf)[8:ncol(indf)][opt$file_num_dimspy]
37 print(filename)
38 # check if the data file is mzML or RAW (can only use mzML currently) so
39 # we expect an mzML file of the same name in the same folder
40 indf$i <- indf[,colnames(indf)==filename]
41 indf[,colnames(indf)==filename] <- as.numeric(indf[,colnames(indf)==filename])
42 37
43 filename = sub("raw", "mzML", filename, ignore.case = TRUE) 38 if (file.exists(opt$mzML_file)){
44 print(filename) 39 mzml_file <- opt$mzML_file
40 }else{
41
42 filename = colnames(indf)[8:ncol(indf)][opt$file_num_dimspy]
43 print(filename)
44 # check if the data file is mzML or RAW (can only use mzML currently) so
45 # we expect an mzML file of the same name in the same folder
46 indf$i <- indf[,colnames(indf)==filename]
47 indf[,colnames(indf)==filename] <- as.numeric(indf[,colnames(indf)==filename])
48
49 filename = sub("raw", "mzML", filename, ignore.case = TRUE)
50 print(filename)
51
52 mzml_file <- file.path(opt$mzML_file, filename)
53
54 }
55
45 df <- indf[4:nrow(indf),] 56 df <- indf[4:nrow(indf),]
46 if ('blank_flag' %in% colnames(df)){ 57 if ('blank_flag' %in% colnames(df)){
47 df <- df[df$blank_flag==1,] 58 df <- df[df$blank_flag==1,]
48 } 59 }
49
50 colnames(df)[colnames(df)=='m.z'] <- 'mz' 60 colnames(df)[colnames(df)=='m.z'] <- 'mz'
51 61
52 if ('nan' %in% df$mz){ 62 if ('nan' %in% df$mz){
53 df[df$mz=='nan',]$mz <- NA 63 df[df$mz=='nan',]$mz <- NA
54 } 64 }
55 df$mz <- as.numeric(df$mz) 65 df$mz <- as.numeric(df$mz)
56 mzml_file <- file.path(opt$mzML_file, filename) 66
57 67
58 68
59 69
60 } 70 }
61 71