Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into error when plotting alpha diversity indexes #365

Open
ChathuZ opened this issue Aug 22, 2024 · 2 comments
Open

Running into error when plotting alpha diversity indexes #365

ChathuZ opened this issue Aug 22, 2024 · 2 comments

Comments

@ChathuZ
Copy link

ChathuZ commented Aug 22, 2024

Here is the error

> ps_obj <- as_phyloseq(obj,
+                       otu_table = presence_data,
+                       otu_id_col = "#OTU ID",
+                       sample_data = sample_data,
+                       sample_id_col = "SampleID")
Error in as_phyloseq(obj, otu_table = presence_data, otu_id_col = "#OTU ID",  : 
  OTU table does not have an OTU ID column named "#OTU ID". Use the "otu_id_col" option if it is named something else.

Here is the full console results up to the error

> #Data quality control
> library(metacoder)
> obj$data$otu_counts <- zero_low_counts(obj, "otu_counts", min_count = 10,
+                                        other_cols = TRUE) # keep OTU_ID column
No `cols` specified, so using all numeric columns:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6

No counts found less than 10.
Warning message:
The following columns will be replaced in the output:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6
 
> 
> print(obj)
<Taxmap>
  1186 taxa: aab. Bacteria, aac. Bacteroidota ... cjf. uncultured_delta, cjl. uncultured_Dokdonella
  1186 edges: NA->aab, aab->aac, aab->aad, aab->aae, aab->aaf ... bhz->cjc, bft->cjd, bng->cje, axx->cjf, bke->cjl
  3 data sets:
    otu_counts:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        22         0         0         0         0         0         0         0        12
      2 avu      cb5168e06325147…        13        10        10         0         0         0        12        14        13
      3 aet      3968cb5b7766a80…        89        13        15        16        22        40        31        14         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_rarefied:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        14         0         0         0         0         0         0         0         7
      2 avu      cb5168e06325147…         9        10         6         0         0         0         7         3         6
      3 aet      3968cb5b7766a80…        49         9         9        12         9        31        18         4         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_props:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…  0.000851  0         0         0         0          0        0         0         0.000387
      2 avu      cb5168e06325147…  0.000503  0.000359  0.000310  0         0          0        0.000474  0.000440  0.000420
      3 aet      3968cb5b7766a80…  0.00344   0.000466  0.000465  0.000544  0.000741   0.00161  0.00122   0.000440  0       
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
  0 functions:
> 
> no_reads <- rowSums(obj$data$otu_counts[, sample_data$SampleID]) == 0
> sum(no_reads) # when `sum` is used on a TRUE/FALSE vector it counts TRUEs
[1] 0
> 
> obj <- filter_obs(obj, "otu_counts", ! no_reads, drop_taxa = TRUE)
> print(obj)
<Taxmap>
  1186 taxa: aab. Bacteria, aac. Bacteroidota ... cjf. uncultured_delta, cjl. uncultured_Dokdonella
  1186 edges: NA->aab, aab->aac, aab->aad, aab->aae, aab->aaf ... bhz->cjc, bft->cjd, bng->cje, axx->cjf, bke->cjl
  3 data sets:
    otu_counts:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        22         0         0         0         0         0         0         0        12
      2 avu      cb5168e06325147…        13        10        10         0         0         0        12        14        13
      3 aet      3968cb5b7766a80…        89        13        15        16        22        40        31        14         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_rarefied:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        14         0         0         0         0         0         0         0         7
      2 avu      cb5168e06325147…         9        10         6         0         0         0         7         3         6
      3 aet      3968cb5b7766a80…        49         9         9        12         9        31        18         4         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_props:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…  0.000851  0         0         0         0          0        0         0         0.000387
      2 avu      cb5168e06325147…  0.000503  0.000359  0.000310  0         0          0        0.000474  0.000440  0.000420
      3 aet      3968cb5b7766a80…  0.00344   0.000466  0.000465  0.000544  0.000741   0.00161  0.00122   0.000440  0       
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
  0 functions:
> 
> 
> hist(colSums(obj$data$otu_counts[, sample_data$SampleID]))
> 
> obj$data$otu_rarefied <- rarefy_obs(obj, "otu_counts", other_cols = TRUE)
No `cols` specified, so using all numeric columns:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6

Rarefying to 16141 since that is the lowest sample total.
Warning messages:
1: In vegan::rrarefy(t(count_table), sample = sample_size) :
  function should be used for observed counts, but smallest count is 10
2: The following columns will be replaced in the output:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6
 
> print(obj)
<Taxmap>
  1186 taxa: aab. Bacteria, aac. Bacteroidota ... cjf. uncultured_delta, cjl. uncultured_Dokdonella
  1186 edges: NA->aab, aab->aac, aab->aad, aab->aae, aab->aaf ... bhz->cjc, bft->cjd, bng->cje, axx->cjf, bke->cjl
  3 data sets:
    otu_counts:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        22         0         0         0         0         0         0         0        12
      2 avu      cb5168e06325147…        13        10        10         0         0         0        12        14        13
      3 aet      3968cb5b7766a80…        89        13        15        16        22        40        31        14         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_rarefied:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        14         0         0         0         0         0         0         0         4
      2 avu      cb5168e06325147…         7         5         5         0         0         0         8         7         6
      3 aet      3968cb5b7766a80…        60         7         6        11        15        23        18        11         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_props:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…  0.000851  0         0         0         0          0        0         0         0.000387
      2 avu      cb5168e06325147…  0.000503  0.000359  0.000310  0         0          0        0.000474  0.000440  0.000420
      3 aet      3968cb5b7766a80…  0.00344   0.000466  0.000465  0.000544  0.000741   0.00161  0.00122   0.000440  0       
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
  0 functions:
> 
> no_reads <- rowSums(obj$data$otu_rarefied[, sample_data$SampleID]) == 0
> obj <- filter_obs(obj, "otu_rarefied", ! no_reads)
> print(obj)
<Taxmap>
  1186 taxa: aab. Bacteria, aac. Bacteroidota ... cjf. uncultured_delta, cjl. uncultured_Dokdonella
  1186 edges: NA->aab, aab->aac, aab->aad, aab->aae, aab->aaf ... bhz->cjc, bft->cjd, bng->cje, axx->cjf, bke->cjl
  3 data sets:
    otu_counts:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        22         0         0         0         0         0         0         0        12
      2 avu      cb5168e06325147…        13        10        10         0         0         0        12        14        13
      3 aet      3968cb5b7766a80…        89        13        15        16        22        40        31        14         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_rarefied:
      # A tibble: 2,619 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        14         0         0         0         0         0         0         0         4
      2 avu      cb5168e06325147…         7         5         5         0         0         0         8         7         6
      3 aet      3968cb5b7766a80…        60         7         6        11        15        23        18        11         0
      # ℹ 2,616 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_props:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…  0.000851  0         0         0         0          0        0         0         0.000387
      2 avu      cb5168e06325147…  0.000503  0.000359  0.000310  0         0          0        0.000474  0.000440  0.000420
      3 aet      3968cb5b7766a80…  0.00344   0.000466  0.000465  0.000544  0.000741   0.00161  0.00122   0.000440  0       
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
  0 functions:
> 
> 
> obj$data$otu_props <- calc_obs_props(obj, "otu_counts", other_cols = TRUE)
No `cols` specified, so using all numeric columns:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6

Calculating proportions from counts for 72 columns for 2620 observations.
Warning message:
The following columns will be replaced in the output:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6
 
> print(obj)
<Taxmap>
  1186 taxa: aab. Bacteria, aac. Bacteroidota ... cjf. uncultured_delta, cjl. uncultured_Dokdonella
  1186 edges: NA->aab, aab->aac, aab->aad, aab->aae, aab->aaf ... bhz->cjc, bft->cjd, bng->cje, axx->cjf, bke->cjl
  3 data sets:
    otu_counts:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        22         0         0         0         0         0         0         0        12
      2 avu      cb5168e06325147…        13        10        10         0         0         0        12        14        13
      3 aet      3968cb5b7766a80…        89        13        15        16        22        40        31        14         0
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_rarefied:
      # A tibble: 2,619 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…        14         0         0         0         0         0         0         0         4
      2 avu      cb5168e06325147…         7         5         5         0         0         0         8         7         6
      3 aet      3968cb5b7766a80…        60         7         6        11        15        23        18        11         0
      # ℹ 2,616 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
    otu_props:
      # A tibble: 2,620 × 74
        taxon_id `#OTU ID`        `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3`
        <chr>    <chr>                <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>     <dbl>
      1 bnk      8ffd3dc50d6274b…  0.000851  0         0         0         0          0        0         0         0.000387
      2 avu      cb5168e06325147…  0.000503  0.000359  0.000310  0         0          0        0.000474  0.000440  0.000420
      3 aet      3968cb5b7766a80…  0.00344   0.000466  0.000465  0.000544  0.000741   0.00161  0.00122   0.000440  0       
      # ℹ 2,617 more rows
      # ℹ 63 more variables: `DR40X-4` <dbl>, `DR40X-5` <dbl>, `DR40X-6` <dbl>, `DR20X-1` <dbl>, `DR20X-2` <dbl>,
      #   `DR20X-3` <dbl>, `DR20X-4` <dbl>, `DR20X-5` <dbl>, `DR20X-6` <dbl>, `DR80M-1` <dbl>, …
      # ℹ Use `print(n = ...)` to see more rows, and `colnames()` to see all variable names
  0 functions:
> 
> 
> 
> ########################
>   library(vegan)
>   rarecurve(t(obj$data$otu_counts[, "DR80X-1"]), step = 20,
+             sample = min(colSums(obj$data$otu_counts[, sample_data$SampleID])),
+             col = "blue", cex = 1.5)
Warning message:
In rarecurve(t(obj$data$otu_counts[, "DR80X-1"]), step = 20, sample = min(colSums(obj$data$otu_counts[,  :
  most observed count data have counts 1, but smallest count is 10
> 
> counts_to_presence(obj, "otu_rarefied")
No `cols` specified, so using all numeric columns:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6

# A tibble: 2,619 × 73
   taxon_id `DR80X-1` `DR80X-2` `DR80X-3` `DR80X-4` `DR80X-5` `DR80X-6` `DR40X-1` `DR40X-2` `DR40X-3` `DR40X-4` `DR40X-5` `DR40X-6`
   <chr>    <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>     <lgl>    
 1 bnk      TRUE      FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     TRUE      TRUE      FALSE     FALSE    
 2 avu      TRUE      TRUE      TRUE      FALSE     FALSE     FALSE     TRUE      TRUE      TRUE      FALSE     TRUE      FALSE    
 3 aet      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      FALSE     TRUE      TRUE      TRUE     
 4 bnm      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE     
 5 als      FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE    
 6 bnn      FALSE     FALSE     TRUE      TRUE      FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     TRUE     
 7 alu      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      FALSE     TRUE      TRUE      TRUE      TRUE      TRUE     
 8 bnp      FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE    
 9 bnr      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE      TRUE     
10 awh      FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE     FALSE    
# ℹ 2,609 more rows
# ℹ 60 more variables: `DR20X-1` <lgl>, `DR20X-2` <lgl>, `DR20X-3` <lgl>, `DR20X-4` <lgl>, `DR20X-5` <lgl>, `DR20X-6` <lgl>,
#   `DR80M-1` <lgl>, `DR80M-2` <lgl>, `DR80M-3` <lgl>, `DR80M-4` <lgl>, `DR80M-5` <lgl>, `DR80M-6` <lgl>, `DR40M-1` <lgl>,
#   `DR40M-2` <lgl>, `DR40M-3` <lgl>, `DR40M-4` <lgl>, `DR40M-5` <lgl>, `DR40M-6` <lgl>, `DR20M-1` <lgl>, `DR20M-2` <lgl>,
#   `DR20M-3` <lgl>, `DR20M-4` <lgl>, `DR20M-5` <lgl>, `DR20M-6` <lgl>, `RC80X-1` <lgl>, `RC80X-2` <lgl>, `RC80X-3` <lgl>,
#   `RC80X-4` <lgl>, `RC80X-5` <lgl>, `RC80X-6` <lgl>, `RC40X-1` <lgl>, `RC40X-2` <lgl>, `RC40X-3` <lgl>, `RC40X-4` <lgl>,
#   `RC40X-5` <lgl>, `RC40X-6` <lgl>, `RC20X-1` <lgl>, `RC20X-2` <lgl>, `RC20X-3` <lgl>, `RC20X-4` <lgl>, `RC20X-5` <lgl>, …
# ℹ Use `print(n = ...)` to see more rows
> # Apply the function
> presence_data <- counts_to_presence(obj, "otu_rarefied")
No `cols` specified, so using all numeric columns:
   DR80X-1, DR80X-2, DR80X-3, DR80X-4, DR80X-5, DR80X-6, DR40X-1 ... RC20M-1, RC20M-2, RC20M-3, RC20M-4, RC20M-5, RC20M-6

> packageVersion("phyloseq")
[1] ‘1.41.1’
> 
> # Example of converting to a phyloseq object (if needed)
> ps_obj <- as_phyloseq(obj,
+                       otu_table = presence_data,
+                       otu_id_col = "#OTU ID",
+                       sample_data = sample_data,
+                       sample_id_col = "SampleID")
Error in as_phyloseq(obj, otu_table = presence_data, otu_id_col = "#OTU ID",  : 
  OTU table does not have an OTU ID column named "#OTU ID". Use the "otu_id_col" option if it is named something else.
> 
@ChathuZ
Copy link
Author

ChathuZ commented Aug 22, 2024

This worked for me. Is it ok to continue with this?

ps_obj <- as_phyloseq(obj,
                      otu_table = obj$data$otu_rarefied,
                      otu_id_col = "#OTU ID",
                      sample_data = sample_data,
                      sample_id_col = "SampleID")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@ChathuZ and others