EESI / themetagenomics

Other
23 stars 4 forks source link

Error in `[.data.frame`(tax_table, , g) : undefined columns selected #2

Open anmwinter opened 6 years ago

anmwinter commented 6 years ago

Hello,

I was able to run the full analysis of the DAVID sample data. When I load in my own data from csv files as dataframes I get this error: Error in[.data.frame(tax_table, , g) : undefined columns selected

after running

CLEAN <- prepare_data(otu_table=abund,
                      rows_are_taxa=FALSE,
                      tax_table=taxa,
                      metadata=meta,
                      formula=~Latitude,
                      cn_normalize=FALSE,
                      drop=TRUE)

my otu table looks like this:

abund[1:5,1:5]
          1 2      3   4 5
BIdB11 2541 0    415 390 0
BIdB21 7270 0    482 448 0
BIdB31 1150 0 248526 130 0
BIdB41 2095 0    550 831 0
BIdB51 1157 0    251 238 0

my taxa table:

taxa[1:5,1:5]
       Kingdom         Phylum Class          Order         Family
1 "Unassigned"          "UAP" "UAC"        "Other"        "Other"
2 "Unassigned"          "UAP" "UAC"        "Other"        "Other"
3  "Chromista" "unidentified" "UAC" "unidentified" "unidentified"
4      "Fungi"          "UAP" "UAC"        "Other"        "Other"
5      "Fungi"          "UAP" "UAC"        "Other"        "Other"

and meta table:

meta[1:5,1:5]
           ID Latitude  pH Nitrogen.Total Carbon.Total
BIdB11 BIdB11 73.21889 8.3            0.1          4.5
BIdB21 BIdB21 73.21889 8.3            0.1          4.5
BIdB31 BIdB31 73.21889 8.3            0.1          4.5
BIdB41 BIdB41 73.21889 8.3            0.1          4.5
BIdB51 BIdB51 73.21889 8.3            0.1          4.5

The best I could figure was there is something wrong with the way I am reading in the taxa table. It looks like the DAVID$TAX is a list and not a dataframe? Do I need to wrangle my taxa table into a list?

Thanks! ara

anmwinter commented 6 years ago

I solved it. The tax and abund need to be convert to a matrix first so as.matrix(read.table(foo and stuff)).