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

Error in if (class(dis) %in% "phylo") { : the condition has length > 1 #31

Open
chemy-cm opened this issue Jan 19, 2024 · 1 comment
Open
Labels

Comments

@chemy-cm
Copy link

My Code:

# Merge seq and tree
OTU <- otu_table(species_otu_table, taxa_are_rows = TRUE)

physeq <- phyloseq(OTU, otu_tree)

# Count
phy_SES <- phyloseq_phylo_ses(
  physeq,
  measures = c("PD", "MPD", "VPD"),
  null_model = "richness",
  package = "picante",
  abundance_weighted = FALSE,
  nsim = 1000,
  swapiter = 1000,
)

Error information:

SES analysis started at  10:06:44 
Error in if (class(dis) %in% "phylo") { : the condition has length > 1

I can used this function to calculate "PD" and "MPD", But not "VPD" parameter.

> phy_SES <- phyloseq_phylo_ses(
+   physeq,
+   measures = c("PD", "MPD"),
+   null_model = "richness",
+   package = "picante",
+   abundance_weighted = FALSE,
+   nsim = 1000,
+   swapiter = 1000,
+ )
SES analysis started at  10:12:25 
..Randomizing data with 'richness' algorithm
  |===================================================================================================| 100%
..Estimating phylogenetic diversity for the randomized data
  |===================================================================================================| 100%
..Estimating effect size
..Done
Analysis finished at  10:12:37

I guess the "VPD" calculate got wrong.

Show "OTU" content:

> OTU
OTU Table:          [17 taxa and 32 samples]
                     taxa are rows
                              LYG1  LYG2 LYG3  LYG4 LYG5  LYG6 LYG7 LYG8  LYG9 LYG10 LYG11 LYG12 LYG13 LYG14
Amblychaeturichthys_hexanema     0     0    0     0    0     0    0    0     0     0     0     0     0     0
Chaeturichthys_stigmatias     7509 13980 5698 36438 2463 31835 2985 4479  8514 11374 13725  3886 43904 44243
Coilia_nasus                     0     0    0     0    0     0    0    0     0    31     0    33     0     0
Collichthys_lucidus           1339   119   70    71  189  3421 2064 3032  1273  6879  2141  2081     0     0
Ctenotrypauchen_chinensis        0     0    0     0    0     0    0    0     0     0     0     0     0     0
Cynoglossus_joyneri          10944   442 3136  5513 4444  4426 4067 1640  1909  2166  5682  1345  5810  4196
Engraulis_japonicus           2882   274  201 19840  530   921 5837 8303 18928  6489    28   502    21   402
Hexagrammos_otakii              69    12    0    12   37   718    7  453  1152    38    14  2264  1089  1808
Konosirus_punctatus             40     0    0    15    0     0    0    0     0     0    18  1280  3551    19
Larimichthys_polyactis        1002     0    0     0  704    53   12   15    13    14    27  1198     0     0
Liparis_tanakae               1026   105    0     0   52   577    0    0  1304  9149  1754     0   275  1161
Lophius_litulon                901  7363 1295   132   45   803   33 1578   222    62     8  1222  1402   823
Odontamblyopus_lacepedii         0     0    0     0    0     0    0    0     0     0     0     0    53   508
Pholis_fangi                   971    35 1865    68 3233   235 6094 2609 12732   188  1050  2014   747   387
Scomber_japonicus                0     0    0     0    0     0    0    0     0     0     0     0     0     0
Setipinna_taty                 106     0   16    53   63    14  767 1903  1574    23  3796    25     8     0
Thryssa_kammalensis            603 11153  880    41 1014  2611 4213   24  2874  3058  3038  4066    22  2424
                             LYG15 LYG16  ZH1  ZH2 ZH3  ZH4  ZH5  ZH6  ZH7  ZH8  ZH9  ZH12 ZH13 ZH15 ZH16
Amblychaeturichthys_hexanema    47    28    0    0   0    0    0    0    0    0    0     0    0    0    0
Chaeturichthys_stigmatias    32321 27175 1160    9   8    0    0    0    0 2529    0    36    0  256    0
Coilia_nasus                     0     0    0    0   0    0    0    0    0    0 1853   246    7    0  105
Collichthys_lucidus             58    40    0    0   0    0    0    0    9    0    0     0  540  587    9
Ctenotrypauchen_chinensis        0     0    0    0   0    0 1148    0    0  864    0    14    0  270 1479
Cynoglossus_joyneri           5682  5531    0    0   0    0    0    0    0    0    0     0    0    0    0
Engraulis_japonicus           2395  3425 6344 4096 949 2462  187 2594 2363 7442 4109   269 2084  448  128
Hexagrammos_otakii               7    70    0    0   0    0    0    0    0    0    0     0    0    0    0
Konosirus_punctatus            923  4595    0    0   0    0    0    0    0    0    0     0    0    0    0
Larimichthys_polyactis           0    19    0    0   0    0    0    0    0    0    0     0    0    0    0
Liparis_tanakae                 44     0  662   67  10   24   13    0 6061 1400 1229 11768   20  465    0
Lophius_litulon                 11    48    0    0   0    0    0    0    0    0    0     0    0    0    0
Odontamblyopus_lacepedii       568    19    0    0   0    0    0    0    0    0    0     0    0    0    0
Pholis_fangi                  3256   101    0    0   0    0    0    0  351    0    0     0    0    8    0
Scomber_japonicus                0     0    0    0   0 3093    0   13    0    0    0     0    0    0    0
Setipinna_taty                 828  1910    0    0   0    0    0    0    0    0    0     0    0    0    0
Thryssa_kammalensis           4896   152    0    0   0    0    0    0    0    0    0     0    0    0    0
                              ZH17  ZH18 ZH19
Amblychaeturichthys_hexanema     0     0    0
Chaeturichthys_stigmatias        6     0   21
Coilia_nasus                    24    12    0
Collichthys_lucidus              0     0    7
Ctenotrypauchen_chinensis       14    12    0
Cynoglossus_joyneri              0     0    0
Engraulis_japonicus          16132 10753 7846
Hexagrammos_otakii               0     0    0
Konosirus_punctatus              0     0    0
Larimichthys_polyactis           0     0    0
Liparis_tanakae                 26  1209 2092
Lophius_litulon                  0     0    0
Odontamblyopus_lacepedii         0     0    0
Pholis_fangi                     0     0 1956
Scomber_japonicus                0     0    0
Setipinna_taty                   0     0    0
Thryssa_kammalensis              0     0    0

Show "otu_tree" content:

> otu_tree

Phylogenetic tree with 17 tips and 15 internal nodes.

Tip labels:
  Amblychaeturichthys_hexanema, Chaeturichthys_stigmatias, Ctenotrypauchen_chinensis, Odontamblyopus_lacepedii, Hexagrammos_otakii, Pholis_fangi, ...

Unrooted; includes branch lengths.

How can I fix this error?
Many Thanks!

@vmikk
Copy link
Owner

vmikk commented Jan 19, 2024

Hello Ming,

Thank you for reporting the issue.
I've fixed the problem (closed via 5e9c680). Please pull the latest version of metagMisc.

It works on a test dataset:

library(phyloseq)
library(metagMisc)

data("GlobalPatterns")

res <- phyloseq_phylo_ses(
  physeq = GlobalPatterns,
  measures = c("PD", "MPD", "VPD"),
  null_model = "richness",
  package = "picante",
  abundance_weighted = FALSE,
  nsim = 5,
  swapiter = 5
)

Unfortunately, multi-threading is not implemented yet for the diversity estimation for the randomized datasets, so it may take a while to run.

@vmikk vmikk added the bug label Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants