Closed ghost closed 6 years ago
Yes, of course there is. See importTxt
, importTab
or importCsv
in MALDIquantForeign
.
Could you please describe the format of your text files (and the line of codes you try to use them)?
I had seen MALDIQuant Foreign but did not know the use of the package. I will try running my code using instrunctions from the vignette and get back to you.
When I used ImportCSV, I received the following error: Error in import(path = path, type = "csv", ...) : Import failed! Unsupported file type? I then just used the general import function and my data was uploaded as a variable into the workspace. spectra<-import("E:/Data/Kundai/RStudio/MALDI")
I then tried carrying out quality control and the functions gave the following errors:
any(sapply(spectra, isEmpty)) Error in FUN(X[[i]], ...) : isEmpty() is not defined for objects of class MassSpectrum plot(spectra[[1]])
I then tried running the following lines of code and these are the errors I received. ( I have a folder which has 5 MALDI spectra with simple labels e.g K8 but the columns are not labelled.) I personally think the problems lies in the function failing to label the different files, but I am no expert, just a beginner).
samples <- factor(sapply(spectra, function(x)metaData(x)$sampleName)) Error in sort.list(y) : 'x' muss atomar sein für 'sort.list' Haben Sie 'sort' für eine Liste aufgerufen? avgSpectra <- averageMassSpectra(spectra, labels=samples, method="mean") Error in as.vector(x, "character") : cannot coerce type 'closure' to vector of type 'character'. If I remove the "labels=samples", the line runs well but then I receive the following error when I continue with the next line of code. noise <- estimateNoise(avgSpectra[[1]]) Error in avgSpectra[[1]] : this S4 class is not subsettable plot(avgSpectra[[1]], xlim=c(4000, 5000), ylim=c(0, 0.002)) Error in avgSpectra[[1]] : this S4 class is not subsettable
Can you send me an example file?
The error Error in import(path = path, type = "csv", ...) : Import failed! Unsupported file type?
arises because you file is not a CSV file but a txt file (not comma but space separated).
You could use:
library("MALDIquant")
library("MALDIquantForeign")
## single file
spectra <- importTxt("K8.txt")
## whole folder:
spectra <- importTxt(".")
## or use just "import" which tries to find the correct file type automatically
spectra <- import("K8.txt")
## or for directories
spectra <- import("E:/Data/Kundai/RStudio/MALDI") # as you did already
plot(spectra[[1]])
Thank you. What about application of quality control functions and labeling of files to enable plotting of average spectra. I am still getting the following error :
plot(avgSpectra[[1]], xlim=c(4000, 5000), ylim=c(0, 0.002)) Error in avgSpectra[[1]] : this S4 class is not subsettable
I have been zealously following the vignette and since the following line of code produces an error: samples <- factor(sapply(spectra,function(x)metaData(x)$sampleName))
Any operation after the said point is producing an error. Whats the best way for me to be able to label my data ? I need this part to ensure that I can detect peaks, do peak binning and produce a feature matrix.
I have been zealously following the vignette and since the following line of code produces an error:
samples <- factor(sapply(spectra,function(x)metaData(x)$sampleName))
That's not working because the sampleName
could only generated from files that contain metadata, e.g. bruker fid files, mzML files etc.
txt, csv, tab and so on don't contain any metadata (except the file name). That's why you can't use this to get your samples. You have to create the samples
variable from the file names or manually.
I am still getting the following error :
plot(avgSpectra[[1]], xlim=c(4000, 5000), ylim=c(0, 0.002)) Error in avgSpectra[[1]] : this S4 class is not subsettable
If you build just one average spectrum you have to use
plot(avgSpectra)
instead ofplot(avgSpectra[[1]])
(the output ofaverageMassSpectra
depends on thelabels
argument, if no label was given all spectra are averaged into on spectrum, otherwise a average spectrum per level is generated).
Thank you for your patience, attention and help.
Everytime I try to use the plot function extracting data from txt files in workspace, I get the following error messages:
Error in plot.window(...) : endliche 'ylim' Werte nötig In addition: Warning messages: 1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by coercion 2: In min(x) : no non-missing arguments to min; returning Inf 3: In max(x) : no non-missing arguments to max; returning -Inf
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘transformIntensity’ for signature ‘"character"’
Matrix products: default
locale: [1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252 [4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages: [1] stats4 parallel stats graphics grDevices utils datasets methods base
other attached packages: [1] randomForest_4.6-12 data.table_1.10.4 dbscan_1.1-1 bindrcpp_0.2
[5] plotly_4.7.1 ggplot2_2.2.1 shiny_1.0.5 KPIC_2.4.0
[9] protViz_0.2.31 devtools_1.13.3 cleaver_1.15.1 Biostrings_2.45.4
[13] XVector_0.17.1 IRanges_2.11.15 S4Vectors_0.15.7 BiocInstaller_1.27.4
[17] MALDIquantForeign_0.11 MALDIquant_1.16.4 ProtGenerics_1.9.0 BiocParallel_1.11.6
[21] mzR_2.11.8 Rcpp_0.12.12 Biobase_2.37.2 BiocGenerics_0.23.1
loaded via a namespace (and not attached): [1] purrr_0.2.3 GA_3.0.2 lattice_0.20-35 colorspace_1.3-2
[5] viridisLite_0.2.0 htmltools_0.3.6 yaml_2.1.14 base64enc_0.1-3
[9] XML_3.98-1.9 rlang_0.1.2 glue_1.1.1 withr_2.0.0
[13] foreach_1.4.3 plyr_1.8.4 bindr_0.1 zlibbioc_1.23.0
[17] munsell_0.4.3 gtable_0.2.0 htmlwidgets_0.9 codetools_0.2-15
[21] memoise_1.1.0 crosstalk_1.0.0 httpuv_1.3.5 xtable_1.8-2
[25] scales_0.5.0 jsonlite_1.5 mime_0.5 impute_1.51.0
[29] digest_0.6.12 dplyr_0.7.3 readBrukerFlexData_1.8.5 grid_3.4.1
[33] tools_3.4.1 magrittr_1.5 lazyeval_0.2.0 readMzXmlData_2.8.1
[37] tibble_1.3.4 tidyr_0.7.1 pkgconfig_2.0.1 assertthat_0.2.0
[41] httr_1.3.1 iterators_1.0.8 R6_2.2.2 git2r_0.19.0
[45] compiler_3.4.1
Is there a way of extracting and processing data from txt files ?