OpenAlex Python Toolkit for Librarians
Abstract
This workshop will focus on using Python to retrieve institutionally affiliated bibliometric data (e.g. articles, datasets, books, etc.) from the OpenAlex API. Participants will be supplied with pre-written Python code that can be run from Google Colab to generate reports and data visualizations of research outputs from their organization.
Full text
OpenAlex Python Toolkit for Librarians Chad Hutchens, Chair, Digital Collections UW Libraries [email protected] Katharine Teykl , Chair, Digital Inquiry, Visualization, and Exploration (DIVE) UW Libraries [email protected]
Today's Agenda Part 1 (9-10:30) •Introductions & Use Cases •How comfortable are you with APIs and Python? •Overview of OpenAlex •Setup, Google Colab, & Basic Python Orientation •Looking up your ROR ID •Part 1 Exercises: The OpenAlex API and Basic Analyses Using Data From Your Institution Part 2 (10:45-12:15) •Part 2 Exercises: Visualizations with Python & Matplotlib •Advanced Exercises (if time permits)
Overview of OpenAlex •Free and open SKG (Scientific Knowledge Graph) of global research •Alternative to Scopus, Dimensions, WoS •Data sources are varied, but open & documented •Documentation: https://docs.openalex.org/ •Google Group: https://groups.google.com/g/openalex-users •Twitter/X: https://x.com/openalex_org https://openalex.org/about
Comparison of Data Sources https://openalex.org/about •Prior to early November, OA had ~270 million works in their dataset. •OA added ~190 million new works 2 weeks ago, bringing the total works to ~460 million
OpenAlex Data Access •Three options for accessing OA Data •GUI: https://openalex.org/works •API: https://api.openalex.org https://docs.openalex.org/how-to-use-the-api/apioverview •Data Snapshot (~300GB): https://docs.openalex.org/download-alldata/openalex-snapshot
Python Intro ●Python is an open source, general use programming language : https://www.python.org/ ●Object-oriented: focused around working with data (objects) rather than functions or logic' ●Strong focus on syntax and readability ●PEP 8 Style Guide - syntax guidelines Python can be used in many different IDEs, including Google Colab ohttps://colab.research.google.com/
Jupyter Notebook Intro •https://jupyter.org/ •Outgrowth of the IPython Project (ca. 2014) but now supports all programming languages, including Python •Numerous ways to use/install/run Jupyter notebook •Using PIP (Package Manager) •Anaconda •Use Jupyter on the web *(Colab, JupyterLite, your local compute cluster, etc) + "Jupyter Notebooks are a community standard for communicating and performing interactive computing." - jupyter.org
Google Colab Intro •Google Colab is web based, free, and hosted Jupyter notebook service (requires a Google account) •A Jupyter notebook file (.ipynb) is stored in Google Drive (or Github) •https://colab.research.google.com/ •We will go over Basic Python on Colab before we jump into exercises +
Google Colab Setup •Let's get everyone into Colab (requires Google Account) •Open provided Jupyter notebook files (.ipynb) in Google Drive (or USB) and make local copies! •Basic tour of Colab and Python + https://colab.research.google.com/
Part 1, Exercise 4: Item Type Breakdown •Link to Exercise 4: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v#s crollTo=fy0sbF_gw7jY •This will build a count of publications broken down by item type, in alphabetical order •OpenAlex has 15 different item types documented here: https://docs.openalex.org/api-entities/works/work-object#type
Part 1, Exercise 5: Filter Pubs by Item Type •Link to Exercise 5: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1 v#scrollTo=7tlpN4v-x2HR •This will build a count of works of a specific item type over all time •To change the item type, be sure to spell it exactly as Open Alex does. You can use the breakdown in Exercise 4 to get other examples, but we have used "dataset" in this example.
Part 1, Exercise 6: Open v. Closed Access Status •Link to Exercise 6: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v# scrollTo=Tl7VY12JwN7G •This counts the number of open and closed access works for one year •You may change the year, of course
Part 1, Exercise 7: OA Status Breakdown •Link to Exercise 7: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v #scrollTo=jvyMmvNry4Vh •This breaks down all works in one year by the type of open access status •Open Alex has 6 different open access statuses documented here: https://docs.openalex.org/api-entities/works/work-object#oa_status.
Part 1, Exercise 8: Work Count by Publisher •Link to Exercise 8: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v #scrollTo=V__SbOsHzII4 •This will count the number of works by publisher in one year. •The publisher may be accessed by looking at the "host organization" field.
Part 1, Exercise 9: Breakdown by Source •Link to Exercise 9: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v# scrollTo=4lkkwVB63AHj •This will breakdown the number of works by source in one year •Think of a source as, for example, a journal title, repository name, conference name, etc.
Part 1, Exercise 10a: Work Count by Author •Link to Exercise 10a: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v# scrollTo=htE4i2Xv0UHu •This will build a list of the Top 25 most published authors at your institution ordered by work count for one year. •NB: You will need to run this query using the full ROR ID string, not just the identifier
Part 1, Exercise 10b: Most Cited Authors •Link to Exercise 10b: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v# scrollTo=G7Rrlwn2UvtL •This will build a list of the Top 200 most cited authors at your institution ordered by citation count. •NB: You will need to run this query using the full ROR ID string, not just the identifier
Part 1, Exercise 11: Locating Publications using DOI •Link to Exercise 11: https://colab.research.google.com/drive/1AaJ7JVi3UiSl11XQYd1TRVbpxxkBMq1v# scrollTo=ZtbrECp_0ecV •This will retrieve all metadata associated with a single DOI •NB: We have omitted abstracts here, discuss
10 Minute Break or Catch-Up •When we return, we will move onto Part 2: Data Analysis & Visualization •Visualization Basics with matplotlib: https://colab.research.google.com/drive/1URW8FBE1IVnCIM2JQhSE8WZgndknPBE5?usp=sharing •Link to Part 2 Jupyter Notebook: https://colab.research.google.com/drive/1CgZTKXtmmLSAeYm9dJspFDdE2vyO1JRX?usp=sh aring •We'll be working from Part 2 for the next hour +
Visualization Exercise 3: Open vs Closed Access Pubs by Year •Link to Visualization Exercise 3: https://colab.research.google.com/drive/1CgZTKXtmmLSAeYm9dJspFDdE2vyO1J RX#scrollTo=DV9h-uJEzQ50 •This will create a line graph charting the number of open and closed access publications over a period of years. •You may change the years, of course.
Visualization Exercise 4: OA Status Breakdown for One Year •Link to Visualization Exercise 4: https://colab.research.google.com/drive/1CgZTKXtmmLSAeYm9dJspFDdE2vyO1J RX#scrollTo=_fVj1ImG2Bc4 •This will create a bar graph charting the breakdown of the different open access statuses for all publications in a single year. •You may change the year, of course.
Visualization Exercise 6: Top 10 Discplines in One Year •Link to Visualization Exercise 6: https://colab.research.google.com/drive/1CgZTKXtmmLSAeYm9dJspFDdE2vyO1J RX#scrollTo=XXFGtunZ2hie •This will create a bar graph of the Top 10 disciplines assigned to publications in one year. •You may change the year, of course. •Discussion of how Open Alex assigns topics.
Advanced Exercises •Link to Advanced Exercise Jupyter Notebook: https://colab.research.google.com/drive/1GffpBsZK9NIrxZV9FWhOlYp2XuTfWKC?usp=sharing •If we have time, we will get into these exercises. Otherwise, we've made them available for your reference at a later date.
Questions? Chad Hutchens, Chair, Digital Collections, UW Libraries 307-766-5560 [email protected] Katharine Teykl , Chair, Digital Inquiry, Visualization, and Exploration (DIVE) UW Libraries [email protected]