Giter Site home page Giter Site logo

sgibb / maldiquantforeign Goto Github PK

View Code? Open in Web Editor NEW
9.0 7.0 4.0 412 KB

Import/Export routines for MALDIquant

Home Page: https://strimmerlab.github.io/software/maldiquant/

R 99.04% JetBrains MPS 0.28% TeX 0.67%
mzml r csv msd-files import export maldi mass-spectrometry

maldiquantforeign's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

maldiquantforeign's Issues

unitAccession not followed by unitName

Hi, in this cvParam only the unitAccession is given, but the unitName is not given; please consider adding unitName="number of counts" to the function in line 329 to make it valid mzML

.writeXmlTag("cvParam", intend=3, file=file,
attrs=c(cvRef="MS", accession="MS:1000515",
name="intensity array", unitCvRef="MS",
unitAccession="MS:1000131"))

Error when skipping lines in text file

Hi,
Thanks for this package.
I guess that the beginning of the code L24-L35 is guessing the right parameters for read.table. But then read.table L38 is not applied to the raw file but to already processed text lines. Because skipping lines already took place, it should not be applied twice. I think that the file name actually should be given to read.table L38 instead of the text variable.
Best.

text <- readLines(file, encoding=encoding)
text <- tail(text, length(text) - skip)
text <- text[!startsWith(trimws(text), comment.char)]
if (is.null(sep)) {
sep <- .autoSep(text)
}
if (is.null(header)) {
header <- .autoHeader(text, sep=sep)
}
## load ms file
s <- read.table(text=text, header=header, sep=sep, skip=skip,
comment.char=comment.char, stringsAsFactors=FALSE, ...)

.writeImzMlDocument doesn't pass the 'processed' argument to .addIbdOffsets

In the .writeImzMlDocument function, .addIbdOffsets gets called without the processed argument, leading to .addIbdOffsets using always the default (=TRUE). Subsequently, a wrong imzml file is created,
which makes the exported data unusable.
Original function:

.writeImzMlDocument <- function(x, file,
                                id=.withoutFileExtension(basename(file)),
                                processed=TRUE, uuid=.uuid(),
                                coordinates=MALDIquant::coordinates(x),
                                pixelSize=c(metaData(x[[1L]])$imaging$pixelSize,
                                            100, 100)[1L:2L], ...) {

...

  .writeMzMlDocument(x=.addIbdOffsets(x), file=file, id=id,
                     imsArgs=list(uuid=uuid, sha1=sha1, processed=processed),
                     ...)
}

Suggested fix:

.writeImzMlDocument <- function(x, file,
                                id=.withoutFileExtension(basename(file)),
                                processed=TRUE, uuid=.uuid(),
                                coordinates=MALDIquant::coordinates(x),
                                pixelSize=c(metaData(x[[1L]])$imaging$pixelSize,
                                            100, 100)[1L:2L], ...) {

...

  .writeMzMlDocument(x=.addIbdOffsets(x, processed=processed), file=file, id=id,
                     imsArgs=list(uuid=uuid, sha1=sha1, processed=processed),
                     ...)
}

Import centroided data as MassPeaks

mzXML and mzML have a flag for centroided data.
For all other formats an argument centroided=TRUE or a function asMassPeaks would be fine.

Unable to write imzML files via exportImzMl

exportImzMl complains when attempting writing to an imzML file, here is a reproducible example (file attached
massPeaksList.gz ):

s <- readRDS(file = "massPeaksList.gz")
MALDIquantForeign::exportImzMl(x = s, path = "test.imzML", processed = TRUE)

Error in get(as.character(FUN), mode = "function", envir = envir) : 
  object 'coordinates<-' of mode 'function' was not found
  
packageVersion("MALDIquantForeign")
[1] ‘0.12’

The issue is resolved when explicitly loading MALDIquant into the environment. The issue appears to be in .writeImzMlDocument function in imzMl-functions.R line #48 coordinates(x) <- coordinates, the function coordinates is called without specifying MALDIquant package namespace.

Also the documentation of ?MALDIquantForeign::exportImzMl says the the input should be "a MassSpectrum object or a list of MassSpectrum objects" but it didn't have any issues exporting a list of MassPeaks objects (the attached file).

Warning when exporting imzML and faulty imzML

I want to export some IMS data as imzML file with the exportImzMl function. During the process I get the following warning:
Warning message:
In .ibdOffsets(x, processed = processed, encodedLengthSize = encodedLengthSize) :
integer overflow in 'cumsum'; use 'cumsum(as.numeric(.))'
The resulting imzML file has "NA" value for most of the "external offset" entries. Additionally, even with processed=FALSE the external offset value in mzArray is always a different value, while it should be the, if I understood it correctly.
The data set, that I want to convert, is relatively large (7953 spectra, 36713 data points each, around 3 GB object size).

MALDIquantForeign generates and prints a warning for every spectrum when reading imzML

I have been evaluating multiple imzML parsers (see here https://imzml.github.io/) with publicly available imzML datasets (e.g. https://metaspace2020.eu/datasets?ds=2017-06-30_07h26m26s) and experienced some issues with MALDIquantForeign.

It seems that if a common 'error' is encountered for each spectrum, then this will flood the console with one message per spectrum (which for MSI Data is a lot!) eventually leading to a system crash. The error for the dataset linked above is given below. Perhaps it would be possible to just display the warning once per dataset, rather than per spectrum?

- Warning in .createMassObject(mass = mass, intensity = intensity, metaData = m, :
-    According to the metadata information the imported data are centroided, but they are treated as profile (MassSpectrum) data. Maybe you want to use 'centroided=TRUE'. See '?import' for details.

parallel support

Parsing XML files takes longer than reading them. So all XML parsing import functions could benefit from parallelization.

fix methods NOTE

Package in Depends field not imported from: ‘methods’
These packages needs to imported from for the case when
this namespace is loaded but not attached.
See the information on DESCRIPTION files in the chapter ‘Creating R
packages’ of the ‘Writing R Extensions’ manual.

move tests

testthat 0.8 comes with a new recommended structure for storing your tests. To
better meet CRAN recommended practices, testthat now recommend that you to put
your tests in tests/testthat, instead of inst/test (this makes it
possible for users to choose whether or not to install tests). With this
new structure, you'll need to use test_check() instead of test_packages()
in the test file (usually tests/testthat.R) that runs all testthat unit
tests.

Reading/Converting Bruker's MALDI-FTICR .d file

Hi Sebastian,

I would like to use MALDIQuant to analyse Bruker's MALDI-FTICR data. But I don't know how do I convert the raw file to mzML file or other MALDIquantForeign supported format. Or will MALDIquantForeign support such data type?

Here I upload a compressed sample data. The acquired data is basically a folder, which contains various files in it. It can be opened with Bruker's DataAnalysis software, and can be exported to, for instance, .xml or .ascii file. But the software does not support exporting to mzML format.

Here I attached one example data, could you please help?
WT.d.zip

Thanks a lot.

Dong

add possibility to ignore specific path/files

It would be useful to avoid importing of some files (e.g. Bruker LIFT files or calibration runs):

Maybe an ignorePattern argument should be added to import.

Typical directory tree (we want only import 0_L19/1SRef/fid and ignore all *LIFT/1SRef/fid files):

├── 0_L19
│   │   └── 1
│   │       ├── 1247.4076.LIFT
│   │       │   └── 1SRef
│   │       │       ├── acqu
│   │       │       ├── acqus
│   │       │       ├── fid
│   │       │       └── sptype
│   │       ├── 1290.4581.LIFT
│   │       │   └── 1SRef
│   │       │       ├── acqu
│   │       │       ├── acqus
│   │       │       ├── fid
│   │       │       └── sptype
│   │       ├── 1SRef
│   │       │   ├── acqu
│   │       │   ├── acqus
│   │       │   ├── fid
│   │       │   └── sptype
│   │       ├── 2089.7704.LIFT
...

Error when reading Analyze7.5 files

Hi,
I am wondering if this check can be relaxed or changed into a warning:
if (size != 348 && size != 384) { stop(sQuote(filename), " is no ANALYZE header file.") }
I have some Analyze7.5 files that do not match this size requirement but work for example in Cardinal.
Thanks,
Melanie

Must this package depend on R>=3.2.2 ?

Hello,

I'm puzzled as to why MALDIquant can work with R>=3.2.0 but MALDIquantForeign depends on R>=3.2.2. If this is not necessary, please amend MALDIquantForeign to depend on R>=3.2.0

many thanks,

Simon

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.