Open santoshe1 opened 4 years ago
How do you propose we try to reproduce your error?
First, try the code below to see if it succeeds
library(flowCore)
library(flowWorkspace)
data("GvHD")
fs <- GvHD[1:2]
gs <- GatingSet(fs)
gs
Then, provide some more context of your use case and code, paste the traceback()
output and sessionInfo,
lastly, it would be helpful to provide the minimum reproducible example (as suggested by @gfinak )
@mikejiang the code you posted works for me, no problem.
However, I also am getting the same error as @santoshe1 and this is a (relatively) new problem. I will provide you with a test case that works and a test case that does not work, complete with sample data, tomorrow.
@mikejiang in Experiment 1, a flowset is created successfully but we fail to create a gatingset, with the same error as reported above by @santoshe1.
# > source("https://bioconductor.org/biocLite.R")
# > biocLite()
library("Biobase")
library("flowCore")
library("flowWorkspace")
# Set this to the correct directory
#setwd("/Users/gp/Developer/flowworkspace-test-case")
pData <- read.table("Experiment1_phenoData.txt", row.names=1, header=TRUE, sep="\t")
pData$Filename <- row.names(pData)
row.names(pData) <- pData$Filename
phenoData <- new("AnnotatedDataFrame", data=pData)
flowset <- read.flowSet(
dataset=1,
transformation=FALSE,
alter.names=TRUE,
phenoData = phenoData
)
gatingset <- GatingSet(flowset)
In Experiment 2, both flowset and gatingset are created successfully.
# > source("https://bioconductor.org/biocLite.R")
# > biocLite()
library("Biobase")
library("flowCore")
library("flowWorkspace")
# Set this to the correct directory
#setwd("/Users/gp/Developer/flowworkspace-test-case")
pData <- read.table("Experiment2_phenoData.txt", header=TRUE, sep="\t")
phenoData <- new("AnnotatedDataFrame", data=pData)
flowset <- read.flowSet(
dataset=1,
transformation=FALSE,
alter.names=TRUE,
phenoData=phenoData
)
gatingset <- GatingSet(flowset)
Complete test cases: https://drive.google.com/drive/folders/1JJWsCYgMjPeWVFKBm0GfXMp2gTlLDb3I
It should be noted that while I was expecting read.flowSet()
to take the row names of the AnnotatedDataFrame
as file paths, it actually requires you to have a column specifically identified as "filename" or "file" (not case-sensitive).
Furthermore, it appears that creating an AnnotatedDataFrame
in this way fails to use column names as default metadata, such that one must write instead:
pData <- read.table("Experiment2_phenoData.txt", header=TRUE, sep="\t")
metadata <- data.frame(labelDescription=colnames(pData), row.names=colnames(pData))
phenoData <- new("AnnotatedDataFrame", data=pData, varMetadata=metadata)
... to have the metadata fields populated. Otherwise they are filled with NA
s.
I understand that this is not an issue with flowWorkspace per se, but if we then take this phenoData
object and pass it to read.flowSet()
, an additional weirdness happens: the metadata contained in the phenoData
is not preserved in the flowset... So I think there may be some funny compatibility issues between biobase and flowCore.
This can all be reproduced with the test case files provided above.
It was due to the /
characters in sampleNames
resulted from the nested subfolders structures in your cases.
head(rownames(pData))
[1] "Experiment1_data/786 n1/786n1_Ca1uM4h_samp_20x 00016119 613.LMD"
[2] "Experiment1_data/786 n1/786n1_Ca1uM4h_samp_60x 00016122 616.LMD"
[3] "Experiment1_data/786 n1/786n1_Ca1uM4h_samp_100x 00016125 619.LMD"
This causes the trouble for write.flowSet
that is invoked by GatingSet
constructor under the hood.
I've pushed the easy fix to flowCore
to substitute them with _
within read.flowSet
i.e.
flowset <- read.flowSet(
+ dataset=1,
+ transformation=FALSE,
+ alter.names=TRUE,
+ phenoData = phenoData
+ )
>
> sampleNames(flowset)
[1] "Experiment1_data_786 n1_786n1_Ca1uM4h_samp_20x 00016119 613.LMD"
[2] "Experiment1_data_786 n1_786n1_Ca1uM4h_samp_60x 00016122 616.LMD"
[3] "Experiment1_data_786 n1_786n1_Ca1uM4h_samp_100x 00016125 619.LMD"
so now it should work for GatingSet
gatingset <- GatingSet(flowset)
> head(sampleNames(gatingset))
[1] "Experiment1_data_786 n1_786n1_Ca1uM4h_samp_20x 00016119 613.LMD"
[2] "Experiment1_data_786 n1_786n1_Ca1uM4h_samp_60x 00016122 616.LMD"
[3] "Experiment1_data_786 n1_786n1_Ca1uM4h_samp_100x 00016125 619.LMD"
Try to pull the latest flowCore
from github and let me know if it works for you.
@mikejiang Ohhhhhhhhh my godddd hahaha. Brilliant, thank you so much!
I had been wrestling with this for many hours yesterday and just could not figure it out. I appreciate the quick fix!
I'm getting the same error, but I'm not sure if I've installed the packages correctly. I ran these:
devtools::install_github("RGLab/cytolib") # 2.1.18
devtools::install_github("RGLab/flowCore") # 2.1.2
devtools::install_github("RGLab/flowWorkspace") # 4.1.9
And then again I got:
> gatingset <- flowWorkspace::GatingSet(flowset)
cannot open file '/var/folders/23/z5mf0z_x2sj5xw7m95mdhgyh0000gn/T//Rtmp5xlcs9/filedee7b860abd/data/786 n1/786n1_Ca1uM4h_samp_20x 00016119 613.LMD': No such file or directoryError in h(simpleError(msg, call)) :
error in evaluating the argument 'x' in selecting a method for function 'GatingSet': cannot open the connection
Scratch that, I restarted my environment and everything seems to work correctly!
Command -
> fs_transformed A flowSet with 130 experiments.
gs <- GatingSet(fs_transformed)
I get an error:
Error in h(simpleError(msg, call)) : error in evaluating the argument 'x' in selecting a method for function 'GatingSet': unimplemented type 'list' in 'EncodeElement'
Kindly assist. Thanks