<jupyter_start><jupyter_text>Fetch dataset metadata<jupyter_code>%matplotlib inline
from metaspace import SMInstance
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>This notebook provides a minimal example of accessing metadata for datasets submitted to [METASPACE](https://metaspace2020.eu)<jupyter_code>sm = SMInstance()

# Log in to METASPACE for access to private datasets. This step can be skipped if you only want to access public datasets.
# This will prompt you to enter your API key if needed and it will save it to a config file.
# Note that API keys should be kept secret like passwords.
sm.save_login()
datasets = sm.datasets()
datasets = datasets[0:3]
datasets
metadata = sm.get_metadata()
metadata.columns.values  # available metadata
ionisation = metadata['MS_Analysis.Ionisation_Source'].value_counts()
ionisation_short = ionisation[:4]
ionisation_short['Other'] = ionisation[4:].sum()
# Plot a pie chart of ionisation sources used
ionisation_short.plot(kind='pie', figsize=(5, 5));
# Plot matrix popularity for MALDI datasets
maldi_metadata =  metadata.loc[metadata['MS_Analysis.Ionisation_Source']=='MALDI']

ax = maldi_metadata['Sample_Preparation.MALDI_Matrix'].value_counts()\
    .plot(kind='bar', figsize=(15, 5), title='MALDI matrices used')
ax.set_ylabel('number of datasets')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10226442658875091, 'fraction_numerical': 0.009495982468955442, 'mean_word_length': 6.873563218390805, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '30964', 'license': 'Apache-2.0', 'n_tokens_mistral': 435, 'n_tokens_neox': 416, 'n_words': 126, 'path': 'metaspace/python-client/docs/source/content/examples/fetch-dataset-metadata.ipynb', 'repo_name': 'mrmattuschka/metaspace', 'size': '1369'}