Entering edit mode
Hi, I am having problems with R when I am using it to analyze the data from Hisat2-Stringtie as in the article Nature,2016.
pheno_data = read.csv("phenotype_data.csv")
bg <- ballgown(dataDir = "ballgown", samplePattern = "NP", pData = pheno_data)
When I run this code I get this error:
# Error in ballgown(dataDir = "ballgown", samplePattern = "NP", pData = pheno_data) :
first column of pData does not match the names of the folders containing the ballgown data.
In addition: Warning message:
In ballgown(dataDir = "ballgown", samplePattern = "NP", pData = pheno_data) :
Rows of pData did not seem to be in the same order as the columns of the expression data. Attempting to rearrange pData...
However, when I do this:
pheno_data = read.csv("phenotype_data.csv")
pheno_data=pheno_data[order(pheno_data$id.state),]
bg <- ballgown(dataDir = "ballgown", samplePattern = "NP", pData = pheno_data)
I get this error:
# Error in ballgown(dataDir = "ballgown", samplePattern = "NP", pData = pheno_data) :
is.null(pData) | class(pData) == "data.frame" is not TRUE
Can you please tell me what am I doing wrong?
Are you sure
pheno_data
is a data.frame?It was probably a data.frame when you loaded the CSV file with
read.csv()
but then you subsetted it to reorder its rows. Please be aware that subsetting can sometimes drop the data.frame class and return an atomic vector (e.g. if the data.frame has a single column). To prevent this usedrop=FALSE
e.g.