Giter Club home page Giter Club logo

Comments (9)

sgibb avatar sgibb commented on August 11, 2024

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)?

from maldiquant.

 avatar commented on August 11, 2024

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.

from maldiquant.

 avatar commented on August 11, 2024

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

from maldiquant.

sgibb avatar sgibb commented on August 11, 2024

Can you send me an example file?

from maldiquant.

 avatar commented on August 11, 2024

K8.txt
L8.txt

Please find attached two txt files as requested.

from maldiquant.

sgibb avatar sgibb commented on August 11, 2024

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]])

from maldiquant.

 avatar commented on August 11, 2024

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.

from maldiquant.

sgibb avatar sgibb commented on August 11, 2024

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 of plot(avgSpectra[[1]]) (the output of averageMassSpectra depends on the labels argument, if no label was given all spectra are averaged into on spectrum, otherwise a average spectrum per level is generated).

from maldiquant.

 avatar commented on August 11, 2024

Thank you for your patience, attention and help.

from maldiquant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.