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

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

Open
emma-wilson opened this issue Dec 13, 2023 · 0 comments

Comments

@emma-wilson
Copy link

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")
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

1 participant