{"id":1282,"date":"2018-02-27T09:53:20","date_gmt":"2018-02-27T09:53:20","guid":{"rendered":"https:\/\/www.dimensions.ai\/?p=1282"},"modified":"2024-10-31T18:27:01","modified_gmt":"2024-10-31T17:27:01","slug":"building-institutional-collaboration-diagrams-with-the-dimensions-search-api","status":"publish","type":"post","link":"https:\/\/www.dimensions.ai\/blog\/building-institutional-collaboration-diagrams-with-the-dimensions-search-api\/","title":{"rendered":"Building institutional collaboration diagrams"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">One of the most refreshing aspects of the Dimensions API is that it is designed to be used on a daily basis by people asking questions about research, and not just by backend systems with complicated integration tasks (although it does this too). With the rise of data science, the ability for an analyst to process data in languages such as python is as important as a mastery of Excel. An analyst now expects to be able to easily query a research database, extract the information they need as a JSON object, and quickly incorporate the information back into their current project.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">To illustrate how the new dimensions search API supports this new way of working, I thought it would be useful to walk through the process of using the API to build an institutional collaboration diagram. Institutional collaboration diagrams can quickly facilitate discussions on an institution&#8217;s collaborative practices and are a common request of research analysts. Without access to an API to retrieve the required information, the process of building collaboration diagrams can often be tiresome and repetitive. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Let&#8217;s get started.<\/span><\/p>\n<p><b>Working through the steps required to build an Institutional collaboration diagram<\/b><\/p>\n<p><span style=\"font-weight: 400;\">An institutional collaboration diagram is typically a network of research institutions that are connected by the number of publications that share common affiliations. For instance, between 2015 to 2018, Heidelberg University researchers published 835 papers with researchers from the German Cancer Research Center researchers. In a network diagram, these institutions would be connected by a line with a width proportional to 835 papers. Extending this further, based on the information that we can see in the Dimensions discovery interface, we can choose to construct a 1-degree network of the top 10 collaborators with Heidelberg University where the width of the edge between the two institutions is proportional to the number of publications co-authored.<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1284 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/Untitled-design-16.png\" alt=\"\" width=\"1920\" height=\"800\" \/><\/p>\n<p>To build out the local institutional collaboration pattern around the University of Heidelberg, we can requery the Dimensions interface again and again to retrieve the top ten collaborating institutions for each of the connecting institutions.\u00a0 In doing so, we can begin to\u00a0visualize a more complex multilateral relationships between institutions.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1285 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-blog-post-3.png\" alt=\"\" width=\"629\" height=\"272\" \/><\/p>\n<p>Of course, the number of queries that we need to undertake increases the greater the number of hops away from the University of Heidelberg we are interested in exploring. A 1-degree network from a source institution will require 11 queries assuming that we limit ourselves to only the top 10 collaborations for each institution. A 2-degree network could take up to 100 queries! Each query requires several steps, first to execute, and then to extract and merge the collaboration data into a single network file. For a 1-degree network, this activity would probably represent the better part of an hour of repetitive work for a dedicated analyst.\u00a0\u00a0 Using the Dimensions Search API (and a small amount of python code) we can complete this activity in minutes, and create a scalable repeatable recipe for looking at far larger networks than it would be possible to create by hand.<\/p>\n<p><strong>Using the Dimensions DSL via the web interface<\/strong><\/p>\n<p>To start with, we can replicate the Dimensions query that we made above using the Dimensions Search API. Once we have logged into <a href=\"https:\/\/dsl.dimensions.ai\/\">https:\/\/dsl.dimensions.ai\/<\/a>, we can express the University of Heidelberg collaboration query as:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1286 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-pic-4.jpg\" alt=\"\" width=\"655\" height=\"141\" \/><\/p>\n<p>(we can look up the GRID id for the University of Heidelberg at <a href=\"https:\/\/grid.ac\/institutes\">https:\/\/grid.ac\/institutes<\/a>)<\/p>\n<p>This query returns a json object that lists out exactly the same publication counts that can be found in the front interface. For many analytic tasks, it is useful to convert these results back to\u00a0 tabular form using a JSON to CSV converter like <a href=\"https:\/\/json-csv.com\/\">https:\/\/json-csv.com\/<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1287 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/Untitled-design-17.png\" alt=\"\" width=\"1920\" height=\"800\" \/><\/p>\n<p>So far we have replicated the same manual experience that we get on the front end, with the Search API. What remains is to script these steps using a programming language such as python.<\/p>\n<p><strong>Using the DSL with python<\/strong><\/p>\n<p><strong>\u00a0<\/strong>To use the dimensions search API with python, we first need to create a function called \u201cdslquery\u201d that acts like the web interface &#8211; it handles authentication, submits queries and returns results in JSON format. As the code for doing this just needs to be written once, it is useful to put this in a separate file that can be imported into all of the scripts that you will write to query the DSL.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1299 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-pic-13.jpg\" alt=\"\" width=\"605\" height=\"40\" \/><\/p>\n<p>Next, we need to parameterise the query that we used above so that it can be generalised for any research institution. We achieve this by wrapping the query as a function that takes a grid institutional id as an input.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1290 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-8.jpg\" alt=\"\" width=\"649\" height=\"172\" \/><\/p>\n<p>We then run the query once to get the list of Institutions that we wish to base our network on.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1291 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-9.jpg\" alt=\"\" width=\"645\" height=\"66\" \/><\/p>\n<p>To create our network, we loop our way through the seed results to build out the top ten Institution edges for each of the institutions identified. This loop will submit 11 queries to the DSL, one for each institution.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1293 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-10-1.jpg\" alt=\"\" width=\"646\" height=\"329\" \/><\/p>\n<p>From here, all that is left to do is to is to export the results to CSV, and then visualise these results in a network visualization tool such as <a href=\"https:\/\/cytoscape.org\/\">cytoscape<\/a>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1294 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-11.jpg\" alt=\"\" width=\"644\" height=\"127\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1295 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-12.png\" alt=\"\" width=\"725\" height=\"637\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1296 aligncenter\" src=\"https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-13.jpg\" alt=\"\" width=\"644\" height=\"57\" \/><\/p>\n<p><strong>Going further<\/strong><\/p>\n<p>Having established the recipe for creating institutional collaboration diagrams, it is easy to create slight modifications that limit the network to a particular field of research or expand the network to all institutions in a country. You could also represent the collaborations on a map by retrieving the longitude and latitude for the institution from the GRID JSON service. (Try <a href=\"https:\/\/grid.ac\/institutes\/grid.7700.0.json\">https:\/\/grid.ac\/institutes\/grid.7700.0.json<\/a> as an example)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Our API wizard, Simon Porter, shares how to build institutional collaboration diagrams using the Dimensions Search API<\/p>\n","protected":false},"author":1,"featured_media":1618,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"latestblog_background":"","latestblog_bgcolor":"","latestblog_textcolor":"","latestblog_overlay":false,"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[],"resource_audience_segment":[],"class_list":["post-1282","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":{"author_name":"Simon Porter","author_image":9781,"header_image":"","cta":""},"featured_image_urls":{"full":["https:\/\/www.dimensions.ai\/wp-content\/uploads\/2018\/02\/API-Blog-Post-pic-12.v1-e1559928274435.png",1000,375,false]},"post_excerpt_dimensions":"<p>Our API wizard, Simon Porter, shares how to build institutional collaboration diagrams using the Dimensions Search API<\/p>\n","category_list":"<a href=\"https:\/\/www.dimensions.ai\/blog\/category\/blog\/\" rel=\"category tag\">Blog<\/a>","author_info":{"name":"admin","url":"https:\/\/www.dimensions.ai\/blog\/author\/admin\/"},"comments_num":"0 comments","_links":{"self":[{"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/posts\/1282","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/comments?post=1282"}],"version-history":[{"count":0,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/posts\/1282\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/media\/1618"}],"wp:attachment":[{"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/media?parent=1282"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/categories?post=1282"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/tags?post=1282"},{"taxonomy":"resource_audience_segment","embeddable":true,"href":"https:\/\/www.dimensions.ai\/wp-json\/wp\/v2\/resource_audience_segment?post=1282"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}