Skip to content

Inconsistencies in "Importing custom data formats" vignette #28

@forsterepi

Description

@forsterepi

Dear GCIMS team,
we tried to use your package with csv files and followed your instructions in the "Importing custom data formats" vignette. We ran into some inconsistencies, however, and are not entirely sure, where the error is.
In the vignette, the intensity() function, which extracts the intensity from the GCIMSSample object, puts the drift times in the first column, i.e., the "rownames". This seems to be in accordance with your description of the intensity matrix as a matrix with length(drift_time) rows. However, in the code you select the top row from the input data, i.e., the "colnames" as the drift times. There is no error in the example, because the input data is symmetrical, but as you can see in the reprex below, when I add another column, there is an error related to the indexes (It wants to select 6 rows, but there are only 5). Where exactly is the error here? Are the definition of retention_time and drift_time the wrong way round?

Reprex:

library(GCIMS)
library(withr)

# Original input
your_csv_file <- (
  ",0.0,0.1,0.2,0.3,0.4
0.0,  0, 20, 80, 84, 23
0.8,123,200,190,295, 17
1.6,230,300,200, 92, 15
2.4,120,150,120, 33, 22
3.2, 70,121, 74, 31, 34
")

csv_data <- withr::with_tempfile("path", fileext = ".csv", {
  write(your_csv_file, path)
  read.csv(path, check.names = FALSE)
})

retention_time <- csv_data[[1]]
drift_time <- as.numeric(colnames(csv_data)[-1])
intensity <- as.matrix(csv_data[,-1])
rownames(intensity) <- retention_time

s1 <- GCIMSSample(
  drift_time = drift_time, 
  retention_time = retention_time,
  data = intensity
)

intensity(s1)
#>      rt_s
#> dt_ms   0 0.8 1.6 2.4 3.2
#>   0     0  20  80  84  23
#>   0.1 123 200 190 295  17
#>   0.2 230 300 200  92  15
#>   0.3 120 150 120  33  22
#>   0.4  70 121  74  31  34
intensity
#>     0.0 0.1 0.2 0.3 0.4
#> 0     0  20  80  84  23
#> 0.8 123 200 190 295  17
#> 1.6 230 300 200  92  15
#> 2.4 120 150 120  33  22
#> 3.2  70 121  74  31  34

# Add column
your_csv_file <- (
  ",0.0,0.1,0.2,0.3,0.4, 0.5
0.0,  0, 20, 80, 84, 23, 1
0.8,123,200,190,295, 17, 2
1.6,230,300,200, 92, 15, 3
2.4,120,150,120, 33, 22, 4
3.2, 70,121, 74, 31, 34, 5
")

csv_data <- withr::with_tempfile("path", fileext = ".csv", {
  write(your_csv_file, path)
  read.csv(path, check.names = FALSE)
})

retention_time <- csv_data[[1]]
drift_time <- as.numeric(colnames(csv_data)[-1])
intensity <- as.matrix(csv_data[,-1])
rownames(intensity) <- retention_time

s1 <- GCIMSSample(
  drift_time = drift_time, 
  retention_time = retention_time,
  data = intensity
)

intensity(s1)
#> Error in `object@data[dt_idx, rt_idx, drop = FALSE]`:
#> ! (subscript) logical subscript too long

Created on 2026-01-29 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions