QFeatures icon indicating copy to clipboard operation
QFeatures copied to clipboard

readQFeatures no longer supports reading from a .txt file

Open lmsimp opened this issue 9 months ago • 6 comments

Hi Laurent,

I have been trying to use the readQFeatures function in the latest release to read in data from an external file e.g. from third party .txt file. To date, this is what we have been doing in our workflows when using QFeatures but now I see this is no longer supported and only now is an option with readSummarizedExperiment?

Would you consider adding the option back to readQFeatures for users so we can create a QFeatures object directly from an external file as per readSummarizedExperiment?

Best,

Lisa


An example,

This works perfectly as the data is already a data.frame

## Get an example PSM file from QFeatures
data("hlpsms")

## Create QF object
qf1 <- readQFeatures(hlpsms, quantCols = 1:10, name = "psms")

Create an example .csv and write it locally a test data

## Now write this data to a .csv as example data to read 
write.csv(hlpsms, file = "hlpsms.csv")

## Check the structure of the .csv
csv <- read.csv(file = "hlpsms.csv")
csv[1:3, 1:3]

# > csv[1:3, 1:3]
# X126      X127C      X127N
# 1 0.12283431 0.08045915 0.07080406
# 2 0.35268185 0.14162381 0.16752388
# 3 0.01546089 0.16142297 0.08693813

If I now try and read from a .csv file I get the following errors

## specify file name
f <- "hlpsms.csv"

grep("X1", names(read.csv(f, sep = ",")))
# [1]  2  3  4  5  6  7  8  9 10 11

## Looks good, quant data is now in 2:11, try read this data
qf2 <- readQFeatures(f, quantCols = 2:11)

# Checking arguments.
# Error in .checkQuantCols(assayData, colData, quantCols) : 
#   Some column names in 'quantCols' are not found in 'assayData': NA, NA, NA, NA, NA, NA, NA, NA, NA, NA.

Also, the same if a character is specified for the quantCols

(id_character <- grep("X1", names(read.csv(f, sep = ",")), value = TRUE))
# [1] "X126"  "X127C" "X127N" "X128C" "X128N" "X129C" "X129N" "X130C" "X130N" "X131" 
qf2 <- readQFeatures(f, quantCols = id_character)

# Checking arguments.
# Error in .checkQuantCols(assayData, colData, quantCols) : 
#   Some column names in 'quantCols' are not found in 'assayData': X126, X127C, X127N, X128C, X128N, X129C, X129N, X130C, X130N, X131.

Works perfectly for SEs

se <- readSummarizedExperiment(f, quantCols = 2:11)
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Ventura 13.2

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats4    stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] MSnbase_2.30.1              ProtGenerics_1.36.0         mzR_2.38.0                 
 [4] Rcpp_1.0.12                 QFeatures_1.14.0            MultiAssayExperiment_1.30.0
 [7] SummarizedExperiment_1.34.0 Biobase_2.64.0              GenomicRanges_1.56.0       
[10] GenomeInfoDb_1.40.0         IRanges_2.38.0              S4Vectors_0.42.0           
[13] BiocGenerics_0.50.0         MatrixGenerics_1.16.0       matrixStats_1.3.0   

lmsimp avatar May 08 '24 15:05 lmsimp