Skip to contents

A wrapper of [openalexR::oa_fetch()] function to get the number of scientific works (and a list of doi if count_only is set to FALSE) for each taxa of a phyloseq object. Each taxa name is searched in the title and abstract of the works present in Open Alex database.

Usage

tax_oa_pq(
  physeq = NULL,
  taxnames = NULL,
  taxonomic_rank = "currentCanonicalSimple",
  count_only = FALSE,
  return_raw_oa = FALSE,
  add_to_phyloseq = NULL,
  col_prefix = NULL,
  type_works = c("article", "review", "book-chapter", "book", "letter"),
  verbose = TRUE,
  discard_genus_alone = taxonomic_rank == "currentCanonicalSimple",
  discard_NA = TRUE,
  ...
)

Arguments

physeq

(optional) A phyloseq object. Either `physeq` or `taxnames` must be provided, but not both.

taxnames

(optional) A character vector of taxonomic names.

taxonomic_rank

(Character, default "currentCanonicalSimple") The column(s) present in the @tax_table slot of the phyloseq object. Can be a vector of two columns (e.g. c("Genus", "Species")).

count_only

(Logical, default FALSE) If TRUE, only the number of works on a given taxa is return, leading to a faster call to `openalexR::oa_fetch()`. Note that if count_only is set to TRUE all works (including e.g. preprint and dataset) are count, leading to higher number of works than if count_only is set to FALSE (see parameter `type_works`).

return_raw_oa

(Logical, default FALSE) If TRUE, return the raw list of publications from Open Alex for each taxa as a list of data.frame. Can be useful to filter works for example by topic or by number of citations (see section examples). If TRUE, add_to_phyloseq is set to FALSE automatically.

add_to_phyloseq

(logical, default TRUE when physeq is provided, FALSE when taxnames is provided and FALSE if return_raw_oa is set to TRUE). If TRUE, return a new phyloseq object with new columns in the tax_table slot. Automatically set to TRUE when a phyloseq object is provided and FALSE when taxnames is provided. Cannot be TRUE if `taxnames` is provided.

col_prefix

A character string to be added as a prefix to the new columns names added to the tax_table slot of the phyloseq object (default: NULL).

type_works

(A list of type to select) See Open Alex [documentation](https://docs.openalex.org/api-entities/works/work-object#type). Only used if count_only is set to FALSE Default is c("article", "review", "book-chapter", "book", "letter").

verbose

(logical, default TRUE) If TRUE, prompt some messages.

...

Other params to passed on [openalexR::oa_fetch()]

Value

Either a tibble (if add_to_phyloseq = FALSE) or a new phyloseq object, if add_to_phyloseq = TRUE, with 1 (`n_doi`) or 4 (`n_doi`, `list_doi`, `n_citation` and `list_keywords` if `count_only` is FALSE) new column(s) in the tax_table.

- n_doi: number of publications citing this taxa in title or abstract - list_doi: list of DOIs separate by ";" - n_citation: total number of citations for all publications citing this taxa - list_keywords: list of keywords from all publications citing this taxa

Details

This function is mainly a wrapper of the work of others. Please cite `openalexR` package.

Author

Adrien Taudiere

Examples

# \donttest{
data_fungi_mini_cleanNames <- gna_verifier_pq(data_fungi_mini) |>
  tax_oa_pq()
#>  GNA verification summary:
#>  Total taxa in phyloseq: 45
#>  Taxa submitted for verification: 37
#>  Genus-level only taxa: 2
#>  Total matches found: 25
#>  Synonyms: 2 (including 2 at genus level)
#>  Accepted names: 23 (including 21 at genus level)
#> Fetching OpenAlex    0% |  ETA: ?
#>  Fetching OpenAlex works for taxon: Stereum ostrea
#> Fetching OpenAlex    0% |  ETA: ?

#> Fetching OpenAlex ■■                                 4% |  ETA:  2m
#>  Fetching OpenAlex works for taxon: Xylodon raduloides
#> Fetching OpenAlex ■■                                 4% |  ETA:  2m

#> Fetching OpenAlex ■■■■                               9% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Stereum hirsutum
#> Fetching OpenAlex ■■■■                               9% |  ETA:  1m

#> Fetching OpenAlex ■■■■■                             13% |  ETA:  2m
#>  Fetching OpenAlex works for taxon: Trametopsis brasiliensis
#> Fetching OpenAlex ■■■■■                             13% |  ETA:  2m

#> Fetching OpenAlex ■■■■■■                            17% |  ETA:  2m
#>  Fetching OpenAlex works for taxon: Basidiodendron eyrei
#> Fetching OpenAlex ■■■■■■                            17% |  ETA:  2m

#> Fetching OpenAlex ■■■■■■■■                          22% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Sistotrema oblongisporum
#> Fetching OpenAlex ■■■■■■■■                          22% |  ETA:  1m

#>  Fetching OpenAlex works for taxon: Fomes fomentarius
#> Fetching OpenAlex ■■■■■■■■                          22% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  2m
#>  Fetching OpenAlex works for taxon: Mycena renati
#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  2m

#>  Fetching OpenAlex works for taxon: Helicogloea pellucida
#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  2m

#>  Fetching OpenAlex works for taxon: Radulomyces molaris
#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  2m

#>  Fetching OpenAlex works for taxon: Elmerina caryae
#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  2m

#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Phanerochaete livescens
#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA:  1m

#>  Fetching OpenAlex works for taxon: Gloeohypochnicium analogum
#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■                57% |  ETA: 38s
#>  Fetching OpenAlex works for taxon: Hyphoderma roseocremeum
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■                57% |  ETA: 38s

#>  Fetching OpenAlex works for taxon: Hyphoderma setigerum
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■                57% |  ETA: 38s

#>  Fetching OpenAlex works for taxon: Trametes versicolor
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■                57% |  ETA: 38s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■            70% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Peniophora versiformis
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■            70% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■           74% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Exidia glandulosa
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■           74% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■          78% |  ETA: 46s
#>  Fetching OpenAlex works for taxon: Peniophorella pubera
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■          78% |  ETA: 46s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% |  ETA: 35s
#>  Fetching OpenAlex works for taxon: Auricularia mesenterica
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% |  ETA: 35s

#>  Fetching OpenAlex works for taxon: Laetisaria buckii
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% |  ETA: 35s

#>  Fetching OpenAlex works for taxon: Hericium coralloides
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% |  ETA: 35s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    96% |  ETA:  8s
#>  Fetching OpenAlex works for taxon: Xylodon flaviporus
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    96% |  ETA:  8s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% |  ETA:  0s
#> 

ggplot(
  subset_taxa(data_fungi_mini_cleanNames, !is.na(n_doi))@tax_table,
  aes(
    x = log10(as.numeric(n_doi)),
    y = forcats::fct_reorder(currentCanonicalSimple, as.numeric(n_doi))
  )
) +
  geom_point(aes(col = Order)) +
  xlab("Number of Scientific Papers (log10 scale)")


tax_oa_pq(data_fungi_mini_cleanNames, type_works = "dataset")
#> Fetching OpenAlex    0% |  ETA: ?
#>  Fetching OpenAlex works for taxon: Stereum ostrea
#> Fetching OpenAlex    0% |  ETA: ?

#>  Fetching OpenAlex works for taxon: Xylodon raduloides
#> Fetching OpenAlex    0% |  ETA: ?

#> Fetching OpenAlex ■■■■                               9% |  ETA: 39s
#>  Fetching OpenAlex works for taxon: Stereum hirsutum
#> Fetching OpenAlex ■■■■                               9% |  ETA: 39s

#> Fetching OpenAlex ■■■■■                             13% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Trametopsis brasiliensis
#> Fetching OpenAlex ■■■■■                             13% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■                            17% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Basidiodendron eyrei
#> Fetching OpenAlex ■■■■■■                            17% |  ETA:  1m

#>  Fetching OpenAlex works for taxon: Sistotrema oblongisporum
#> Fetching OpenAlex ■■■■■■                            17% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■                         26% |  ETA: 42s
#>  Fetching OpenAlex works for taxon: Fomes fomentarius
#> Fetching OpenAlex ■■■■■■■■■                         26% |  ETA: 42s

#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Mycena renati
#> Fetching OpenAlex ■■■■■■■■■■                        30% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■■                       35% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Helicogloea pellucida
#> Fetching OpenAlex ■■■■■■■■■■■                       35% |  ETA:  1m

#>  Fetching OpenAlex works for taxon: Radulomyces molaris
#> Fetching OpenAlex ■■■■■■■■■■■                       35% |  ETA:  1m

#>  Fetching OpenAlex works for taxon: Elmerina caryae
#> Fetching OpenAlex ■■■■■■■■■■■                       35% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA: 40s
#>  Fetching OpenAlex works for taxon: Phanerochaete livescens
#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA: 40s

#>  Fetching OpenAlex works for taxon: Gloeohypochnicium analogum
#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA: 40s

#>  Fetching OpenAlex works for taxon: Hyphoderma roseocremeum
#> Fetching OpenAlex ■■■■■■■■■■■■■■■                   48% |  ETA: 40s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■               61% |  ETA: 26s
#>  Fetching OpenAlex works for taxon: Hyphoderma setigerum
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■               61% |  ETA: 26s

#>  Fetching OpenAlex works for taxon: Trametes versicolor
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■               61% |  ETA: 26s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■            70% |  ETA:  1m
#>  Fetching OpenAlex works for taxon: Peniophora versiformis
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■            70% |  ETA:  1m

#>  Fetching OpenAlex works for taxon: Exidia glandulosa
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■            70% |  ETA:  1m

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■          78% |  ETA: 44s
#>  Fetching OpenAlex works for taxon: Peniophorella pubera
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■          78% |  ETA: 44s

#>  Fetching OpenAlex works for taxon: Auricularia mesenterica
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■          78% |  ETA: 44s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■       87% |  ETA: 24s
#>  Fetching OpenAlex works for taxon: Laetisaria buckii
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■       87% |  ETA: 24s

#>  Fetching OpenAlex works for taxon: Hericium coralloides
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■       87% |  ETA: 24s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    96% |  ETA:  8s
#>  Fetching OpenAlex works for taxon: Xylodon flaviporus
#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■    96% |  ETA:  8s

#> Fetching OpenAlex ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% |  ETA:  0s
#> 
#> Warning: Column names already exist in tax_table: "n_doi", "list_doi", "n_citation", and
#> "list_keywords"
#>  Adding prefix 'oa_' to avoid conflicts
#> phyloseq-class experiment-level object
#> otu_table()   OTU Table:         [ 45 taxa and 137 samples ]
#> sample_data() Sample Data:       [ 137 samples by 7 sample variables ]
#> tax_table()   Taxonomy Table:    [ 45 taxa by 28 taxonomic ranks ]
#> refseq()      DNAStringSet:      [ 45 reference sequences ]


list_pub_raw <- tax_oa_pq(data_fungi_mini_cleanNames,
  col_prefix = "oa_",
  return_raw_oa = TRUE
)
#>  `add_to_phyloseq` is set to FALSE when `return_raw_oa` is TRUE
#>  Fetching OpenAlex works for taxon: Stereum ostrea
#>  Fetching OpenAlex works for taxon: Xylodon raduloides
#> ■■■■■                             13% | ETA: 24s
#>  Fetching OpenAlex works for taxon: Stereum hirsutum
#> ■■■■■                             13% | ETA: 24s

#> ■■■■■■                            17% | ETA:  1m
#>  Fetching OpenAlex works for taxon: Trametopsis brasiliensis
#> ■■■■■■                            17% | ETA:  1m

#>  Fetching OpenAlex works for taxon: Basidiodendron eyrei
#> ■■■■■■                            17% | ETA:  1m

#>  Fetching OpenAlex works for taxon: Sistotrema oblongisporum
#> ■■■■■■                            17% | ETA:  1m

#> ■■■■■■■■■■                        30% | ETA: 35s
#>  Fetching OpenAlex works for taxon: Fomes fomentarius
#> ■■■■■■■■■■                        30% | ETA: 35s

#> ■■■■■■■■■■■                       35% | ETA:  1m
#>  Fetching OpenAlex works for taxon: Mycena renati
#> ■■■■■■■■■■■                       35% | ETA:  1m

#>  Fetching OpenAlex works for taxon: Helicogloea pellucida
#> ■■■■■■■■■■■                       35% | ETA:  1m

#>  Fetching OpenAlex works for taxon: Radulomyces molaris
#> ■■■■■■■■■■■                       35% | ETA:  1m

#> ■■■■■■■■■■■■■■■                   48% | ETA: 36s
#>  Fetching OpenAlex works for taxon: Elmerina caryae
#> ■■■■■■■■■■■■■■■                   48% | ETA: 36s

#>  Fetching OpenAlex works for taxon: Phanerochaete livescens
#> ■■■■■■■■■■■■■■■                   48% | ETA: 36s

#>  Fetching OpenAlex works for taxon: Gloeohypochnicium analogum
#> ■■■■■■■■■■■■■■■                   48% | ETA: 36s

#> ■■■■■■■■■■■■■■■■■■■               61% | ETA: 24s
#>  Fetching OpenAlex works for taxon: Hyphoderma roseocremeum
#> ■■■■■■■■■■■■■■■■■■■               61% | ETA: 24s

#>  Fetching OpenAlex works for taxon: Hyphoderma setigerum
#> ■■■■■■■■■■■■■■■■■■■               61% | ETA: 24s

#> ■■■■■■■■■■■■■■■■■■■■■■            70% | ETA: 17s
#>  Fetching OpenAlex works for taxon: Trametes versicolor
#> ■■■■■■■■■■■■■■■■■■■■■■            70% | ETA: 17s

#> ■■■■■■■■■■■■■■■■■■■■■■■           74% | ETA:  1m
#>  Fetching OpenAlex works for taxon: Peniophora versiformis
#> ■■■■■■■■■■■■■■■■■■■■■■■           74% | ETA:  1m

#>  Fetching OpenAlex works for taxon: Exidia glandulosa
#> ■■■■■■■■■■■■■■■■■■■■■■■           74% | ETA:  1m

#> ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% | ETA: 31s
#>  Fetching OpenAlex works for taxon: Peniophorella pubera
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% | ETA: 31s

#>  Fetching OpenAlex works for taxon: Auricularia mesenterica
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■        83% | ETA: 31s

#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      91% | ETA: 14s
#>  Fetching OpenAlex works for taxon: Laetisaria buckii
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      91% | ETA: 14s

#>  Fetching OpenAlex works for taxon: Hericium coralloides
#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■      91% | ETA: 14s

#> ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■  100% | ETA:  0s
#> 
#>  Fetching OpenAlex works for taxon: Xylodon flaviporus

list_pub_Health_science <- lapply(list_pub_raw, function(xx) {
  if (length(xx) == 0) {
    return(NULL)
  } else {
    filter(xx, map_lgl(topics, function(tibble_item) {
      if (is.null(tibble_item) || nrow(tibble_item) == 0) {
        return(FALSE)
      } else {
        any(grepl("Health science",
          tibble_item$display_name[tibble_item$type == "domain"],
          ignore.case = TRUE
        ))
      }
    }))
  }
})


list_pub_Ecology <- lapply(list_pub_raw, function(xx) {
  if (length(xx) == 0) {
    return(NULL)
  } else {
    filter(xx, map_lgl(topics, function(tibble_item) {
      if (is.null(tibble_item) || nrow(tibble_item) == 0) {
        return(FALSE)
      } else {
        any(grepl("Ecology",
          tibble_item$display_name[tibble_item$type == "subfield"],
          ignore.case = TRUE
        ))
      }
    }))
  }
})

list_pub_at_least_ten_citations <-
  lapply(list_pub_raw, function(xx) {
    if (length(xx) == 0) {
      return(NULL)
    } else {
      filter(xx, cited_by_count > 10)
    }
  })
# }