lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
124 stars 50 forks source link

More columns than column names #530

Closed ortizmateujuan closed 3 years ago

ortizmateujuan commented 3 years ago

Hi there,

I'm having trouble with the readMSnSet2 function as it gives me this error back: "more columns than column names".

I think that this may be not be difficult to correct, but for what I've read in different R forums maybe the source of the problem is working with Mac?

I'm working with the supplementary spreadsheet on this article (Nat Commun. 2016; 7: 8992) that is shown as an example in the Bioconductor complete workflow article (doi: 10.12688/f1000research.10411.2, Fig.3).

This is my code so far:

if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")
BiocManager::install("pRoloc")
if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")
BiocManager::install("pRolocGUI")
if (!requireNamespace("BiocManager", quietly = TRUE))
  install.packages("BiocManager")
BiocManager::install("pRolocdata")

library("MSnbase")
library("pRoloc")
library("pRolocGUI")

csvfile <- dir("/Users/ortizmateujuan/Desktop", full.names = TRUE, pattern = "ncomms9992-s2.csv") 
basename(csvfile)
getEcols(csvfile, split = ";", n = 2)
h1 <- readMSnSet2(csvfile, ecol = 8:27, fnames = 1, skip = 1)

This is the output:

Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
  more columns than column names

I hope you can help me because I'm completely new in programming.

Thanks!

lgatto commented 3 years ago

You don't provide enough information to understand what is happening.

ortizmateujuan commented 3 years ago

Sorry, this is the file:

ncomms9992-s2.xlsx

Anyway I've solved it:

Since I had commas as my decimal separator, my .csv files separated the columns with semicolons (that was the reason I used

split = ";"

instead of

split = ","

Even though I tried that, this was not enough so I had to change my Language & Region advanced preferences in my Macbook from Spain to United States. This way it finally reads the .csv file as it is supposed to and the code runs OK.

Thanks anyway for answering!