File size: 6,429 Bytes
1da1c98
 
 
 
 
 
cc5bd12
 
 
1da1c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc5bd12
1da1c98
 
 
 
 
 
 
 
 
 
cc5bd12
1da1c98
 
 
 
 
 
 
 
 
 
 
 
 
 
cc5bd12
 
 
 
 
1da1c98
 
 
cc5bd12
 
1da1c98
cc5bd12
1da1c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc5bd12
 
1da1c98
 
cc5bd12
 
 
1da1c98
 
 
 
 
 
 
 
 
 
 
 
 
 
cc5bd12
 
1da1c98
 
 
 
 
 
 
 
 
 
 
 
 
 
cc5bd12
 
1da1c98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cc5bd12
 
 
1da1c98
 
 
 
 
 
 
 
 
cc5bd12
1da1c98
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
import os
import scholarpy
import pandas as pd
import streamlit as st
import leafmap.foliumap as leafmap
import plotly.express as px
import datetime

current_year = datetime.datetime.now().year

if "dsl" not in st.session_state:
    st.session_state["dsl"] = scholarpy.Dsl()


def app():

    st.title("Search Organizations")
    dsl = st.session_state["dsl"]
    row1_col1, row1_col2 = st.columns([1, 1])

    with row1_col1:
        name = st.text_input("Enter an organization name:", "")

    if name:
        orgs = dsl.search_org_by_name(name, exact_match=False, return_list=True)

        if orgs is not None:
            with row1_col1:
                selected_org = st.selectbox("Select a organization id:", orgs)
                org_id = selected_org.split("|")[0].strip()

                id_info = dsl.search_org_by_id(org_id)

                info_df = scholarpy.json_to_df(id_info, transpose=True)
                info_df.rename(
                    columns={info_df.columns[0]: "Type", info_df.columns[1]: "Value"},
                    inplace=True,
                )
                with row1_col1:
                    st.header("Organization Information")
                    if not info_df.empty:
                        st.dataframe(info_df)
                        leafmap.st_download_button(
                            "Download data", info_df, csv_sep="\t"
                        )
                    else:
                        st.text("No information found")

                with row1_col2:
                    years = st.slider(
                        "Select the start and end year:",
                        1950,
                        current_year + 6,
                        (1980, current_year),
                    )
                    st.header("Publications by year")

                    pubs, fig = dsl.org_pubs_annual_stats(
                        org_id, start_year=years[0], end_year=years[1], return_plot=True
                    )

                    st.text(f'Total number of publications: {pubs["count"].sum():,}')

                    if fig is not None:
                        st.plotly_chart(fig)

                        leafmap.st_download_button(
                            "Download data",
                            pubs,
                            file_name="data.csv",
                            csv_sep="\t",
                        )
                    else:
                        st.text("No publications found")

                with row1_col1:
                    st.header("Top funders")

                    funder_count = st.slider(
                        "Select the number of funders:", 1, 100, 20
                    )

                    funders, fig = dsl.org_grant_funders(
                        org_id, limit=funder_count, return_plot=True
                    )
                    st.text(f'Total funding amount: ${funders["funding"].sum():,}')
                    if fig is not None:
                        st.plotly_chart(fig)
                        leafmap.st_download_button(
                            "Download data",
                            funders,
                            file_name="data.csv",
                            csv_sep="\t",
                        )
                    else:
                        st.text("No funders found")

                with row1_col2:
                    st.header("The number of grants by year")
                    grants, fig_count, fig_amount = dsl.org_grants_annual_stats(
                        org_id, start_year=years[0], end_year=years[1], return_plot=True
                    )

                    st.plotly_chart(fig_count)
                    st.plotly_chart(fig_amount)
                    leafmap.st_download_button(
                        "Download data",
                        grants,
                        file_name="data.csv",
                        csv_sep="\t",
                    )

                with row1_col1:
                    st.header("List of grants")
                    st.text("Only the first 1000 grants are shown")
                    result = dsl.search_grants_by_org(
                        org_id, start_year=years[0], end_year=years[1]
                    )
                    df = result.as_dataframe()
                    if not df.empty:
                        st.dataframe(df)
                        leafmap.st_download_button(
                            "Download data", df, file_name="data.csv", csv_sep="\t"
                        )

                with row1_col1:
                    st.header("Publications most cited in last 2 years")
                    result = dsl.org_pubs_most_cited(org_id, recent=True, limit=100)
                    df = scholarpy.json_to_df(result, transpose=False)
                    if not df.empty:
                        st.dataframe(df)
                        leafmap.st_download_button(
                            "Download data", df, file_name="data.csv", csv_sep="\t"
                        )

                with row1_col2:
                    st.header("Publications most cited - all time")
                    result = dsl.org_pubs_most_cited(org_id, recent=False, limit=100)
                    df = scholarpy.json_to_df(result, transpose=False)
                    if not df.empty:
                        st.dataframe(df)
                        leafmap.st_download_button(
                            "Download data", df, file_name="data.csv", csv_sep="\t"
                        )

                df, area_fig, journal_fig = dsl.org_pubs_top_areas(
                    org_id, return_plot=True
                )
                if not df.empty:
                    with row1_col1:
                        st.header("Research areas of most cited publications")
                        st.plotly_chart(area_fig)
                        # leafmap.st_download_button(
                        #     "Download data", df, file_name="data.csv", csv_sep="\t"
                        # )
                    with row1_col2:
                        st.header("Journals of most cited publications")
                        st.plotly_chart(journal_fig)
                        leafmap.st_download_button(
                            "Download data", df, file_name="data.csv", csv_sep="\t"
                        )
        else:
            st.text("No organizations found")