Skip to content

Potential switch to OpenAlex for retrieving references and cited by info #1

@emma-wilson

Description

@emma-wilson

Investigating the potential to use OpenAlex snowballing for citation chaser functions. Below code as a starting point, but output will need cleaning.

# Load libraries
library(openalexR)
library(ggraph)
library(tidygraph)

# Input DOI (1 or vector)
doi <- c("xxx", "xxx")

# Use OpenAlex to get the OpenAlex IDs for your DOIs
oaid <- oa_fetch(entity = "works", doi = doi, verbose = T)

# Select only the OpenAlex ID column as a vector
oaid <- oaid$id

# Remove prefix to just get OpenAlex ID
oaid <- gsub("https://openalex.org/", "", oaid)

# Get citations and cited by information from OpenAlex using vector of IDs
# In output:
# snowball_docs$nodes$id = the OpenAlex ID for each record
# snowball_docs$nodes$oa_input = TRUE/FALSE; T = ID refers to out of input IDs
# within snowball$edges... 
# for input IDs in "to" -> "from" is records which cite the input
# for input IDs in "from" -> "to" is records in the input record's reference list
snowball_docs <- oa_snowball(oaid, verbose = T)

# Create a graph
# As suggested on https://docs.ropensci.org/openalexR/#%EF%B8%8F-snowball-search
ggraph(graph = as_tbl_graph(snowball_docs), layout = "stress") +
  geom_edge_link(aes(alpha = after_stat(index)), show.legend = FALSE) +
  geom_node_point(aes(fill = oa_input, size = cited_by_count), shape = 21, color = "white") +
  geom_node_label(aes(filter = oa_input, label = id), nudge_y = 0.2, size = 3) +
  scale_edge_width(range = c(0.1, 1.5), guide = "none") +
  scale_size(range = c(3, 10), guide = "none") +
  scale_fill_manual(values = c("#a3ad62", "#d46780"), na.value = "grey", name = "") +
  theme_graph() +
  theme(
    plot.background = element_rect(fill = "transparent", colour = NA),
    panel.background = element_rect(fill = "transparent", colour = NA),
    legend.position = "bottom"
  ) +
  guides(fill = "none")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions