ropensci / taxize

A taxonomic toolbelt for R
https://docs.ropensci.org/taxize
Other
267 stars 60 forks source link

error class2tree output #929

Open jrigbr opened 5 months ago

jrigbr commented 5 months ago

Hello, I am facing this error while running class2tree

> sp_worms_id [1] 138474 138677 104108 494795 138710 125332 130722 144784 129686 231858 369350 124208 127031 133913 273021 123987 124963 132487 140389 [20] 141855

cl <- classification(sp_worms_id, db = 'worms')

head(cl, 3) $138474

A tibble: 11 × 3

name rank id

1 Animalia Kingdom 2 2 Mollusca Phylum 51 3 Bivalvia Class 105 4 Autobranchia Subclass 1424948 5 Heteroconchia Infraclass 1424949 6 Euheterodonta Subterclass 382296 7 Imparidentia Superorder 869600 8 Cardiida Order 869602 9 Tellinoidea Superfamily 14636 10 Semelidae Family 1781 11 Abra Genus 138474

$138677

A tibble: 11 × 3

name rank id

1 Animalia Kingdom 2 2 Mollusca Phylum 51 3 Polyplacophora Class 55 4 Neoloricata Subclass 57 5 Chitonida Order 382003 6 Acanthochitonina Suborder 90 7 Cryptoplacoidea Superfamily 385402 8 Acanthochitonidae Family 91 9 Acanthochitoninae Subfamily 1353774 10 Acanthochitona Genus 137613 11 Acanthochitona fascicularis Species 138677 $`104108` # A tibble: 10 × 3 name rank id 1 Animalia Kingdom 2 2 Arthropoda Phylum 1065 3 Crustacea Subphylum 1066 4 Multicrustacea Superclass 845959 5 Copepoda Class 1080 6 Neocopepoda Infraclass 155876 7 Gymnoplea Superorder 155877 8 Calanoida Order 1100 9 Acartiidae Family 104074 10 Acartia Genus 104108 **tr <- class2tree(cl) Get all ranks and their taxIDs Erreur dans `$<-.data.frame`(`*tmp*`, "rank_df", value = character(0)) : le tableau de remplacement a 0 lignes, le tableau remplacé en a 11** Thank you if you can help me
trvinh commented 5 months ago

Hello @jrigbr , class2tree() currently accepts a list of data frames as input, not a list of tibbles. I have tried to convert your cl list to data frames and it worked.

> sp_worms_id <- c(138474,138677,104108,494795,138710,125332,130722,144784,129686,231858,369350,124208,127031,133913,273021,123987,124963,132487,140389,141855)
> cl <- classification(sp_worms_id, db = 'worms')
> cl <- lapply(cl, as.data.frame)
> tr <- class2tree(cl)
Get all ranks and their taxIDs
Align taxonomy hierarchies...
Taxonomy alignment done!
Calculate distance matrix
Add node labels
> tr$phylo

Phylogenetic tree with 20 tips and 11 internal nodes.

Tip labels:
  Abra, Acanthochitona fascicularis, Acartia, Acetabularia acetabulum, Aeolidiella alderi, Alcyonium coralloides, ...
Node labels:
  NA, Plantae, Animalia, Demospongiae, Teleostei, Echinodermata, ...

Unrooted; includes branch lengths.

I hope it will help you! Best, Vinh