Submit dataset example

Log in to METASPACE

To authenticate with METASPACE, generate an API key from your account page and enter it below

[ ]:
import json
from metaspace import SMInstance

sm = SMInstance()
[ ]:
# 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()

Provide local paths to your imzML and Ibd files

[ ]:
imzml_fn = 'your_path_to_imzMLFile/Name.imzML'
ibd_fn = 'your_path_to_IbdFile/Name.ibd'

Provide metadata for your dataset

[ ]:
dataset_name = 'Sample Name'
metadata = {
    'Data_Type': 'Imaging MS',  # shouldn't be changed
    'Sample_Information': {
        'Organism': 'Species',
        'Organism_Part': 'Organ or organism part',
        'Condition': 'E.g. wildtype, diseased',
        'Sample_Growth_Conditions': 'E.g. intervention, treatment'  # this is an extra field
    },
    'Sample_Preparation': {
        'Sample_Stabilisation': 'Preservation method',
        'Tissue_Modification': 'E.g. chemical modification',
        'MALDI_Matrix': '2,5-dihydroxybenzoic acid (DHB)',
        'MALDI_Matrix_Application': 'ImagePrep',
        'Solvent': 'none'  # this is an extra field
    },
    'MS_Analysis': {
        'Polarity': 'Ion polarity mode[Positive/Negative]',
        'Ionisation_Source': 'E.g. MALDI, DESI',
        'Analyzer': 'E.g. FTICR, Orbitrap',
        'Detector_Resolving_Power': {
            'mz': 400,
            'Resolving_Power': 130000
        },
        'Pixel_Size': {
            'Xaxis': 20,
            'Yaxis': 40
        }
    }
}

Specify list of databases against which you want to analyze your dataset

[ ]:
# Get list of available databases:
print(sm.databases())

Public databases:

[<18:BraChemDB:2018-01>,
 <19:ChEBI:2018-01>,
 <22:HMDB:v4>,
 <23:HMDB-endogenous:v4>,
 <24:LipidMaps:2017-12-12>,
 <25:PAMDB:v1.0>,
 <26:SwissLipids:2018-02-02>,
 <27:HMDB-cotton:v4>,
 <33:ECMDB:2018-12>,
 <38:CoreMetabolome:v3>]
[ ]:
# Databases may be specified either as an integer ID, or in ('name', 'version') form
# Please notice that if you choose more than 3 databases the processing may take a while
databases = [
    22,  # ID 22 corresponds to HMDB v4
    ('ChEBI', '2018-01'), # ('name', 'version') style is also accepted
]

Dataset visibility (Public/Private)

We are currently allow users to choose if they want their datasets and annotations to be available publicly or not. Set the value below to True if you want dataset to be public. If False, dataset will only be visible to yourself, other members of your Group, METASPACE administrators, and members of any Projects you add it to.

[ ]:
is_public = True # or False

Submit the dataset

[ ]:
sm.submit_dataset(
    imzml_fn, ibd_fn, dataset_name,
    metadata, is_public, databases
)
  • In case of successful submission, you should see the Dataset ID like 2021-01-01_10h11m12s. Go to METASPACE to check your annotations!

  • If you get KeyError: 'errors' make sure that you provided API token and try it again

  • If you don’t see any messages at all, please check if correct metadata is provided, especially if you’ve specified Polarity: Positive or Negative.