jtamames / SqueezeMeta

A complete pipeline for metagenomic analysis
GNU General Public License v3.0
365 stars 78 forks source link

Error in aggregate.data.frame... #587

Closed SMOKO2022 closed 1 year ago

SMOKO2022 commented 1 year ago

In R, RDS file seems to load properly but when I subset data:

bacteria=subsetTax(DFI_swabs_microbial, "superkingdom", "Bacteria", trusted_functions_only = T)

(DFI_swabs_microbial is my SQM object), I get the following error:

Error in aggregate.data.frame(as.data.frame(x), ...) : no rows to aggregate

SMOKO2022 commented 1 year ago

NROW(DFI_swabs_microbial) [1] 7

fpusan commented 1 year ago

Hi! I assume you loaded the data using loadSQM, and then exported it to an RDS file, and loaded it back later with readRDS. Is this correct? Does the problem also happen when using loadSQM directly instead of loading from a RDS file?

SMOKO2022 commented 1 year ago

Hi, thank you for your help. My colleague performed the SqueezeMeta run on our server and sent the RDS file for me to analyse using R on my local machine. We are using different versions of R (3.5.? and 4.2.2). Could this cause an issue in the subsetTax function? My colleague is able to subsetTax without problems on his local machine using the same file.

fpusan commented 1 year ago

Hi, Sorry for the delayed answer, I'm on parental leave. Once you load the RDS file, try running library(data.table) before doing anything else.

SMOKO2022 commented 1 year ago

Hi,

No worries and congrats. I'm still getting the same error:

library(pheatmap) library(ggplot2) library(ggrepel) library(plyr) library(scater) library(scales) library(SQMtools) library(pathview) library(gage) library(reshape2) library(dplyr) library(tidyr) library(purrr) library(broom) library(vegan) library(cowplot)

metadata=read.table(file="~/Desktop/DFI swabs/metadata_swabs.csv", stringsAsFactors = F) DFI_swabs_microbial=readRDS("~/Desktop/DFI swabs/DFI_swabs.RDS")

library(data.table)

bacteria=subsetTax(DFI_swabs_microbial, 'superkingdom', 'Bacteria', trusted_functions_only = T)

Error in aggregate.data.frame(as.data.frame(x), ...) : no rows to aggregate

fpusan commented 1 year ago

I have had success using RData files (as obtained using the save function from R). I had a similar issue as you describe when loading them again, but it went away after explicitly loading data.table. It seems that this trick don't work for RDS files. Can you ask your colleage to just share the raw files with you instead? You would need 1) The SqueezeMeta_conf.pl file 2) The results and intermediate directories 3) Ensure that the directory structure and names on your local computer are the same as what is on the server. For example if your output directory was called SqueezeMeta_XXX and the ‘results’, ‘intermediate’, and conf file were in that directory you must also have this same structure on your own computer for SMQtools to locate all of the required files.