HCBravoLab / metagenomeSeq

Statistical analysis for sparse high-throughput sequencing
66 stars 20 forks source link

Merging MRexperiment objects #54

Closed ninaxhua closed 6 years ago

ninaxhua commented 6 years ago

Hello, I'm trying to merge 2 MRexperiment objects. The samples were completed during different runs and biom tables were imported separately. Upstream otu picking was also completed separately (open reference otu picking in QIIME). However, I ran into this issue: Error in[<-(tmp, rownames(y), colnames(y), value = c(0, 0, 0, 0, : subscript out of bounds Is it because the merge is done by row names because there are different samples in the separate runs?

jnpaulson commented 6 years ago

Can you provide a small MRE?

On 2017-11-04 14:50, ninaxhua wrote:

Hello, I'm trying to merge 2 MRexperiment objects. The samples were completed during different runs and biom tables were imported separately. Upstream otu picking was also completed separately (open reference otu picking in QIIME). However, I ran into this issue: Error in[<-(tmp, rownames(y), colnames(y), value = c(0, 0, 0, 0, : subscript out of bounds Is it because the merge is done by row names because there are different samples in the separate runs?

-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2].

Links:

[1] https://github.com/HCBravoLab/metagenomeSeq/issues/54 [2] https://github.com/notifications/unsubscribe-auth/AC5hgwt-1f6w8Ywdoh6jYh1xacS8Uy1Hks5szNwkgaJpZM4QSLDQ

ninaxhua commented 6 years ago

Okay, I've linked the small MRE objects. Code: `featuresToKeep = which(rowSums(g_ms_mr) >= 10000) small_g_ms_mr = g_ms_mr[featuresToKeep,] saveRDS(extract_s_g_mr, file = "small_g_mr", ascii = FALSE, version = NULL, compress = TRUE, refhook = NULL)

featuresToKeep2 = which(rowSums(l_ms_mr) >= 10000) small_l_ms_mr = l_ms_mr[featuresToKeep2,] saveRDS(extract_s_l_mr, file = "small_l_mr", ascii = FALSE, version = NULL, compress = TRUE, refhook = NULL)`

jnpaulson commented 6 years ago

Somehow you were able to include samples that were not present in the phenotype table and/or count matrix. This causes issues and is usually not possible.

Subsetting to just those samples that you have counts for within each of the datasets fixes your issue.


xmat = MRcounts(x)[,match(colnames(x),colnames(MRcounts(x)))]
x2 = newMRexperiment(xmat,phenoData=phenoData(x),featureData=featureData(x))

ymat = MRcounts(y)[,match(colnames(y),colnames(MRcounts(y)))]
y2 = newMRexperiment(ymat,phenoData=phenoData(y),featureData=featureData(y))

mergeMRexperiments(x2,y2)```