File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -850,6 +850,19 @@ def get_projects_treemap(df):
850
850
851
851
852
852
def __get_modalities (df ):
853
+ """
854
+ Get the counts of different modalities from the DataFrame.
855
+
856
+ This function takes a pandas DataFrame as input and extracts the counts of different modalities
857
+ from the 'generalmodality' column of the DataFrame. It returns a dictionary where the keys
858
+ represent the unique modalities, and the values represent their respective counts.
859
+
860
+ Parameters:
861
+ df (pandas.DataFrame): The input DataFrame containing the 'generalmodality' column.
862
+
863
+ Returns:
864
+ dict: A dictionary with modalities as keys and their corresponding counts as values.
865
+ """
853
866
return (df ["generalmodality" ].value_counts ()).to_dict ()
854
867
855
868
Original file line number Diff line number Diff line change 20
20
],
21
21
python_requires = ">=3.6" ,
22
22
)
23
+ import pandas as pd
24
+ import urllib .request
25
+
26
+ url = 'https://download.brainimagelibrary.org/inventory/daily/reports/today.json'
27
+ file_path , _ = urllib .request .urlretrieve (url )
28
+ df = pd .read_json (file_path )
29
+
30
+ #get affiliations
31
+ affiliations = df ['genotype' ].value_counts ().to_dict ()
32
+ affiliations
33
+
34
+ !pip install kaleido
35
+
36
+ import plotly .graph_objects as go
37
+ from datetime import date
38
+
39
+ def create_tree_map (frequency_dict ):
40
+ labels = list (frequency_dict .keys ())
41
+ values = list (frequency_dict .values ())
42
+
43
+ fig = go .Figure (go .Treemap (
44
+ labels = labels ,
45
+ parents = ['' ] * len (labels ),
46
+ values = values ,
47
+ textinfo = 'label+value'
48
+ ))
49
+
50
+ fig .update_layout (title = 'Genotypes' )
51
+
52
+ today = date .today ()
53
+ output_path = f'treemap-{ today .strftime ("%Y%m%d" )} .png'
54
+ fig .write_image (output_path )
55
+ fig .show ()
56
+
57
+ create_tree_map (affiliations )
You can’t perform that action at this time.
0 commit comments