ParkerICI / premessa

R package for pre-processing of mass and flow cytometry data
GNU General Public License v3.0
42 stars 24 forks source link

Error in rename_fcs_parameters_name: is.matrix(m) is not TRUE #31

Closed algebio closed 4 years ago

algebio commented 4 years ago

Hi

I´m getting this error when using files from FCS Express v7:

Warning: Error in rename_fcs_parameters_name: is.matrix(m) is not TRUE 62:

Any idea of where the problem could be?

This is a copy of the structure of one of the fcs files: Formal class 'flowFrame' [package "flowCore"] with 3 slots ..@ exprs : num [1:41381, 1:24] 3.35 3.85 5.01 5.49 5.84 ... .. ..- attr(, "dimnames")=List of 2 .. .. ..$ : NULL .. .. ..$ : Named chr [1:24] "Time" "FSC-A" "FSC-H" "FSC-W" ... .. .. .. ..- attr(, "names")= chr [1:24] "$P1N" "$P2N" "$P3N" "$P4N" ... .. ..- attr(, "ranges")= num [1:24] 262143 262143 382397 262143 262143 ... ..@ parameters :Formal class 'AnnotatedDataFrame' [package "Biobase"] with 4 slots .. .. ..@ varMetadata :'data.frame': 5 obs. of 1 variable: .. .. .. ..$ labelDescription: chr [1:5] "Name of Parameter" "Description of Parameter" "Range of Parameter" "Minimum Parameter Value after Transforamtion" ... .. .. ..@ data :'data.frame': 24 obs. of 5 variables: .. .. .. ..$ name : 'AsIs' Named chr [1:24] "Time" "FSC-A" "FSC-H" "FSC-W" ... .. .. .. .. ..- attr(, "names")= chr [1:24] "$P1N" "$P2N" "$P3N" "$P4N" ... .. .. .. ..$ desc : 'AsIs' Named chr [1:24] NA NA NA NA ... .. .. .. .. ..- attr(*, "names")= chr [1:24] NA NA NA NA ... .. .. .. ..$ range : num [1:24] 262144 262144 382398 262144 262144 ... .. .. .. ..$ minRange: num [1:24] 0 0 0 0 0 0 0 -111 -111 -111 ... .. .. .. ..$ maxRange: num [1:24] 262143 262143 382397 262143 262143 ... .. .. ..@ dimLabels : chr [1:2] "rowNames" "columnNames" .. .. ..@ .classVersion:Formal class 'Versions' [package "Biobase"] with 1 slot .. .. .. .. ..@ .Data:List of 1 .. .. .. .. .. ..$ : int [1:3] 1 1 0 ..@ description:List of 319 .. ..$ FCSversion : chr "3" .. ..$ $BTIM : chr "12:55:01" .. ..$ $BYTEORD : chr "1,2,3,4" .. ..$ $DATATYPE : chr "F" .. ..$ $DATE : chr "29-NOV-2019" .. ..$ $ETIM : chr "12:58:16" .. ..$ $FIL : chr "398160.fcs" .. ..$ $INST : chr " " .. ..$ $MODE : chr "L" .. ..$ $NEXTDATA : chr "0" .. ..$ $P10B : chr "32" .. ..$ $P10E : chr "0,0" .. ..$ $P10G : chr "1.0" .. ..$ $P10N : chr "640 730/45-A" .. ..$ $P10R : chr "2113174" .. ..$ $P10S : chr "PD1" .. ..$ $P10V : chr "555" .. ..$ $P11B : chr "32" .. ..$ $P11E : chr "0,0" .. ..$ $P11G : chr "1.0" .. ..$ $P11N : chr "405 450/50-A" .. ..$ $P11R : chr "262144" .. ..$ $P11S : chr "CXCR3" .. ..$ $P11V : chr "471" .. ..$ $P12B : chr "32" .. ..$ $P12E : chr "0,0" .. ..$ $P12G : chr "1.0" .. ..$ $P12N : chr "405 610/20-A" .. ..$ $P12R : chr "1248827" .. ..$ $P12S : chr "CD57" .. ..$ $P12V : chr "585" .. ..$ $P13B : chr "32" .. ..$ $P13E : chr "0,0" .. ..$ $P13G : chr "1.0" .. ..$ $P13N : chr "405 780/60-A" .. ..$ $P13R : chr "6428500" .. ..$ $P13S : chr "CD4" .. ..$ $P13V : chr "610" .. ..$ $P14B : chr "32" .. ..$ $P14E : chr "0,0" .. ..$ $P14G : chr "1.0" .. ..$ $P14N : chr "355 379/28-A" .. ..$ $P14R : chr "262144" .. ..$ $P14S : chr "CD3" .. ..$ $P14V : chr "565" .. ..$ $P15B : chr "32" .. ..$ $P15E : chr "0,0" .. ..$ $P15G : chr "1.0" .. ..$ $P15N : chr "355 515/30-A" .. ..$ $P15R : chr "415039" .. ..$ $P15S : chr "CD8" .. ..$ $P15V : chr "500" .. ..$ $P16B : chr "32" .. ..$ $P16E : chr "0,0" .. ..$ $P16G : chr "1.0" .. ..$ $P16N : chr "355 740/35-A" .. ..$ $P16R : chr "1470702" .. ..$ $P16S : chr "CD25" .. ..$ $P16V : chr "748" .. ..$ $P17B : chr "32" .. ..$ $P17E : chr "0,0" .. ..$ $P17G : chr "1.0" .. ..$ $P17N : chr "561 586/15-A" .. ..$ $P17R : chr "13737799" .. ..$ $P17S : chr "CCR6" .. ..$ $P17V : chr "556" .. ..$ $P18B : chr "32" .. ..$ $P18E : chr "0,0" .. ..$ $P18G : chr "1.0" .. ..$ $P18N : chr "561 610/20-A" .. ..$ $P18R : chr "3086331" .. ..$ $P18S : chr "CD56" .. ..$ $P18V : chr "516" .. ..$ $P19B : chr "32" .. ..$ $P19E : chr "0,0" .. ..$ $P19G : chr "1.0" .. ..$ $P19N : chr "561 780/60-A" .. ..$ $P19R : chr "262144" .. ..$ $P19S : chr "CCR7" .. ..$ $P19V : chr "516" .. ..$ $P1B : chr "32" .. ..$ $P1E : chr "0,0" .. ..$ $P1G : chr "0.01" .. ..$ $P1N : chr "Time" .. ..$ $P1R : chr "262144" .. ..$ $P20B : chr "32" .. ..$ $P20E : chr "0,0" .. ..$ $P20G : chr "1.0" .. ..$ $P20N : chr "561 710/50-A" .. ..$ $P20R : chr "262144" .. ..$ $P20S : chr "7AAD" .. ..$ $P20V : chr "533" .. ..$ $P21B : chr "32" .. ..$ $P21E : chr "0,0" .. ..$ $P21G : chr "1.0" .. ..$ $P21N : chr "488 695/40-A" .. ..$ $P21R : chr "2727842" .. ..$ $P21S : chr "CD127" .. ..$ $P21V : chr "590" .. .. [list output truncated]

Regards Juan

algebio commented 4 years ago

Found it.

C&P answer from denovo:

"Files exported with V7 holds an additional keyword (which is not present in the original file), called ORIGINAL_SPILL. This has been added to keep track of the original spillover matrix. In V6 the matrix is applied during the export and then deleted. In V7, the spillover matrix is applied during the export and stored in the ORIGINAL_SPILL keyword to keep track of it (it is no longer used as data are already exported with the compensation applied, it is just there for tracking purposes). It seems that premessa does not like this keyword.

What you can do is to export your files in two steps. First export as you did (the file that trigger the error will be created, and the ORIGINAL_SPILL keyword will be added to those exported files) and then re-export that file a second time, to remove the ORIGINAL_SPILL keyword."

jsaintvanne commented 3 years ago

Hi, I would like to do the rename_fcs_parameters_name function to a flowFrame object as you but I obtain the following error :

Browse[1]> rename_fcs_parameters_name(FCS[[1]], names.map)
Error in `$.flowFrame`(ret, "m") : 
  'm' is not a valid parameter in this flowFrame
Subscript out of bounds

How do you deal with your data pliz ? Because you had a flowFrame object on which you applied this function ??

SamGG commented 3 years ago

the fcs object in premessa is a dedicated object constructed with read_fcs https://github.com/ParkerICI/premessa/blob/467d64150297d83832c3960750ac4792c99153fd/R/fcs_io.R#L161-L180

jsaintvanne commented 3 years ago

the fcs object in premessa is a dedicated object constructed with read_fcs

https://github.com/ParkerICI/premessa/blob/467d64150297d83832c3960750ac4792c99153fd/R/fcs_io.R#L161-L180

Yes, I have these 2 solutions but I would like to finish with a flowFrame object at the end... After changing my parameters... Does as_flowFrame on fcs$m can do it ? It looks not but ! But it looks like that @algebio worked directly with a flowFrame object ??

SamGG commented 3 years ago

Correct. as_flowFrame creates a flowFrame using a mandatory expression matrix and an optional flowFrame. The latter is used to assign keywords to the flowFrame resulting from as_flowFrame. The arguments of the function copy_keywords are flowFrames. https://github.com/ParkerICI/premessa/blob/467d64150297d83832c3960750ac4792c99153fd/R/fcs_io.R#L93-L114