Hello all,
I am receiving an error message when running data on metagenomeSeq, the root cause of which I'm unable to trace:
Error in validObject(.Object) :
invalid class “MRexperiment” object: 1: feature numbers differ between assayData and featureData
invalid class “MRexperiment” object: 2: featureNames differ between assayData and featureData
In general, this error message likely has something to do with the fact that there is mismatch of features in the two matrix sets that I'm using, one matrix which is a count matrix, and another matrix which is taxonomy. Despite checking (rechecking, and rechecking), that the name and order of features are the same (visually and using XLS match function), I am unable to understand where the issue is. I'm a relative novice R user (have extensive SAS training, and only now getting into R coding)
My code (#with annotation):
library(metagenomeSeq)
#Load gene count matrix
counts = loadMeta("counts.txt", sep = "\t")
dim(counts$counts)
#Load phenotype data.
pheno = loadPhenoData("pheno.txt", sep = "\t", tran=TRUE)
ord = match(colnames(counts$counts), rownames(pheno))
pheno = pheno[ord, ]
head(pheno)
#Load taxa matrix
taxa = read.delim("taxa.txt", sep = "\t", stringsAsFactors=FALSE,row.names=1)
#Create MRexperiment:
phenotypeData = AnnotatedDataFrame(pheno)
taxaData = AnnotatedDataFrame(taxa)
frontiers = newMRexperiment(counts$counts,phenoData=phenotypeData, featureData=taxaData)
Example counts data (counts.txt):
Gene | Samp 1 | Samp 2 | Samp 3 | Samp 4 | Samp 5 | Samp 6 |
100|FR772051.1|FR772051|Aminoglycosides|Aminoglycoside_O-nucleotidyltransferases|ANT3-DPRIME | 0 | 0 | 0 | 29 | 0 | 0 |
101|unknown_id|unknown_name|MLS|23S_rRNA_methyltransferases|ERMA | 0 | 0 | 0 | 32 | 0 | 0 |
1034|JQ364968.1|JQ364968|betalactams|Class_A_betalactamases|CARB | 0 | 0 | 0 | 0 | 0 | 0 |
105|FR772051.1|FR772051|MLS|ABC_transporter|VGA | 0 | 0 | 0 | 0 | 0 | 0 |
1090|DQ303459.3|DQ303459|betalactams|Class_A_betalactamases|CTX | 0 | 0 | 0 | 0 | 0 | 377 |
1119|M55547.1|TRNTAAB|Aminoglycosides|Aminoglycoside_O-nucleotidyltransferases|ANT3-DPRIME | 0 | 0 | 0 | 0 | 0 | 0 |
1205|JN086160.1|JN086160|MLS|23S_rRNA_methyltransferases|ERMF | 0 | 0 | 0 | 0 | 0 | 0 |
122|AJ579365.1|AJ579365|MLS|Streptogramin_resistance_ATP-binding_cassette_ABC_efflux_pumps|LSA | 0 | 0 | 0 | 0 | 0 | 0 |
126|AJ579365.1|AJ579365|MLS|23S_rRNA_methyltransferases|ERMA | 0 | 0 | 0 | 0 | 0 | 0 |
1261|AY178993.1|AY178993|betalactams|Class_A_betalactamases|CARB | 0 | 0 | 0 | 0 | 0 | 0 |
1268|AB976602.1|AB976602|betalactams|Class_A_betalactamases|CTX | 0 | 0 | 0 | 0 | 0 | 0 |
1374|DQ077487.1|DQ077487|Tetracyclines|Tetracycline_resistance_major_facilitator_superfamily_MFS_efflux_pumps|TET33 | 0 | 0 | 0 | 0 | 0 | 0 |
1390|EU348758.1|EU348758|MLS|23S_rRNA_methyltransferases|ERMA | 0 | 0 | 0 | 0 | 0 | 0 |
143|unknown_id|unknown_name|Tetracyclines|Tetracycline_transcriptional_repressor|TETR|RequiresSNPConfirmation | 0 | 0 | 0 | 0 | 0 | 0 |
Example taxa data (taxa.txt):
Gene | Trait |
100|FR772051.1|FR772051|Aminoglycosides|Aminoglycoside_O-nucleotidyltransferases|ANT3-DPRIME | AMR |
101|unknown_id|unknown_name|MLS|23S_rRNA_methyltransferases|ERMA | AMR |
1034|JQ364968.1|JQ364968|betalactams|Class_A_betalactamases|CARB | AMR |
105|FR772051.1|FR772051|MLS|ABC_transporter|VGA | AMR |
1090|DQ303459.3|DQ303459|betalactams|Class_A_betalactamases|CTX | AMR |
1119|M55547.1|TRNTAAB|Aminoglycosides|Aminoglycoside_O-nucleotidyltransferases|ANT3-DPRIME | AMR |
1205|JN086160.1|JN086160|MLS|23S_rRNA_methyltransferases|ERMF | AMR |
122|AJ579365.1|AJ579365|MLS|Streptogramin_resistance_ATP-binding_cassette_ABC_efflux_pumps|LSA | AMR |
126|AJ579365.1|AJ579365|MLS|23S_rRNA_methyltransferases|ERMA | AMR |
1261|AY178993.1|AY178993|betalactams|Class_A_betalactamases|CARB | AMR |
1268|AB976602.1|AB976602|betalactams|Class_A_betalactamases|CTX | AMR |
1374|DQ077487.1|DQ077487|Tetracyclines|Tetracycline_resistance_major_facilitator_superfamily_MFS_efflux_pumps|TET33 | AMR |
1390|EU348758.1|EU348758|MLS|23S_rRNA_methyltransferases|ERMA | AMR |
143|unknown_id|unknown_name|Tetracyclines|Tetracycline_transcriptional_repressor|TETR|RequiresSNPConfirmation | AMR |
The error occurs when running the last line of script: frontiers = newMRexperiment(counts$counts,phenoData=phenotypeData, featureData=taxaData)
Is there an obvious mistake here that I'm just not seeing? Very grateful for your time and help in addressing this dilemma.-IS