0

I want to create a MSset file (proteomics data, data corresponds to spectral counts) but I get error messages and I am stuck (after reading manuals, helps, forums, etc).

You can get my files here: https://www.dropbox.com/sh/dw7zfgiku6cteba/AADP3U2yxB5LgXy5ykJYFf0ga?dl=0

Here is the code I have tried:

setwd("~/Desktop/analyse")

## The spectral counts data:

data <- as.character(read.delim("sc.txt", header=TRUE,sep="\t", row.names=1, as.is=TRUE))

## Feature meta-data:
fdata <- as.character(read.delim("fdata.txt", header=TRUE,sep="\t", row.names=1, as.is=TRUE))

## Pheno data:
pdata <- as.character(read.delim("pheno.txt", header=TRUE,sep="\t", row.names=1, as.is=TRUE)) 


library("MSnbase")

readMSnSet(exprsFile = data,
                  phenoDataFile = pdata,
                  featureDataFile = fdata,
                  header=TRUE)

This last command returns an error message

Error in file(file, "rt") : invalid 'description' argument

I have verified the following:

class(data)
[1] "character"
class(fdata)
[1] "character"
class(pdata)
[1] "character"

dim(data)
NULL

dim(fdata) 
NULL

dim(pdata) 
NULL

str(data)
 chr [1:15] "c(4, 6, 11, 4, 3, 6, 2, 9, 8, 14, 15, 2, 8, 16, 5, 0, 0, 0, 0, 1, 2, 0, 0, 2, 1, 1, 0, 13, 11, 5, 0, 4, 6, 116,"| __truncated__ ...

str(pdata)
 chr [1:2] "c(\"treatmentA\", \"treatmentA\", \"treatmentA\", \"treatmentA\", \"treatmentA\", \"treatmentB\", \"treatmentB\"| __truncated__ ...

str(fdata)
chr [1:9] "c(222, 273.06, 335.8638, 413.112474, 508.128343, 624.9978619, 768.7473702, 945.5592653, 1163.037896, 1430.53661"| __truncated__ ...

I have also tried, instead of "as.character()", to use "as.matrix()" for "data", and "as.data.frame()" for "fdata" and "pdata".

Dimensions match correctly and are not "NULL" in this case but it does not solve the problem because i get the following message:

Error in (function (file, header = FALSE, sep = "", quote = "\"'", dec = ".",      : 
  'file' must be a character string or connection

If I try:

all(rownames(pdata)==colnames(data))
   TRUE

I have tried to create my MSnSet file with the following (with initial reading as.character...):

MSnSet(data, fdata, pdata)
Error in (function (storage.mode = c("lockedEnvironment", "environment",  : 
  'AssayData' elements with invalid dimensions: 'exprs'

If i read the files "as.matrix" for "data" and "as.data.frame" for "fdata" and "pdata":

> MSnSet(data, fdata, pdata)
Error in validObject(.Object) : 
  invalid class “MSnSet” object: 1: feature numbers differ between assayData     and featureData
invalid class “MSnSet” object: 2: featureNames differ between assayData and     featureData

> row.names(pdata)[1:5]
[1] "sample1" "sample2" "sample3" "sample4" "sample5"
> colnames(data)[1:5]
[1] "sample1" "sample2" "sample3" "sample4" "sample5"
> row.names(data)[1:5]
[1] "prot1" "prot2" "prot3" "prot4" "prot5"
> row.names(fdata)[1:5]
[1] "prot1" "prot2" "prot3" "prot4" "prot5"

So I have no clue where the problem comes from. Any idea on how to create properly my MSnSet file ??

Many thanks in advance for your help.

SkyR

SkyR
  • 185
  • 1
  • 9
  • 1/ I did not know where my problem came from so it was impossible to point clearly the problem; 2/ if I ask without explanations of what I have already tried, comments would have been to search more by myself and explain what i have tried to avoid people to give tips or advices that i have already tested... so i don't understand how to write correctly a question in such a case – SkyR Jun 03 '18 at 10:02

1 Answers1

3

From the argument name and from the help page, phenoDataFile should be the path to the file, not the contents of the file. From your question, I would guess the argument should be phenoDataFile = "~/Desktop/analyse/pheno.txt"

Martin Morgan
  • 45,935
  • 7
  • 84
  • 112
  • Yes indeed it was the problem, and it works now only by indicating the path to the file, but NOT the file itself. – SkyR Jun 03 '18 at 10:09
  • exprsFile = "C:/.../.../analyse/exprsFile.txt" , the previous works, BUT NOT the following: exprsFile = read.delim("C:/.../.../analyse/exprsFile.txt") – SkyR Jun 03 '18 at 10:11
  • idem for featuredata and phenodata. Then, the MSnSet object is created with the command: readMSnSet(exprsFile, phenoDataFile, featureDataFile, sep ="\", leader = TRUE) – SkyR Jun 03 '18 at 10:13
  • Many thanks Martin Morgan – SkyR Jun 03 '18 at 10:14