Introduction
A Mantle analysis object encapsulates an analysis notebook and links to the notebook’s inputs, as well as its output datasets and files.
Getting an analysis by unique ID
Get an analysis by its unique ID
import mantlebio
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. get( "analysis-id" )
Mantle datasets can be retrieved using their unique ID and added as inputs to an analysis.
Get dataset by ID and add it as an input to an analysis
import mantlebio
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. get( "analysis-id" )
dataset = mantle. dataset. get( "dataset-id" )
analysis. add_input( "my_dataset_input" , dataset)
Track file inputs in your analysis by adding file inputs, specifying a key to identify the input and the file’s local path.
Add a file input to an analysis
import mantlebio
import os
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. get( "analysis-id" )
analysis. add_file_input( "my_file_input" , f" { os. getcwd( ) } /some_input.txt" )
Track string or Boolean inputs by specifying the input key and value.
Add a Python string or Boolean input to an analysis
import mantlebio
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. get( "analysis-id" )
analysis. add_input( "my_string_input" , "some string" )
analysis. add_input( "my_boolean_input" , True )
Adding outputs to analyses
Adding a dataset output to an analysis
Add dataset outputs to an analysis to track the generated outputs, providing a key to identify the output as well as the output file’s path.
import mantlebio
mantle = mantlebio. MantleClient( )
dataset = mantle. dataset. create(
name= "4XP1" ,
local= False ,
properties= {
"description" : "X-ray structure of Drosophila dopamine transporter bound to neurotransmitter dopamine" ,
"resolution" : 2.5 ,
"r_value" : 0.2 ,
}
)
analysis = mantle. analysis. get( "analysis-id" )
analysis. add_output( 'my_output_dataset' , dataset)
Adding a file output to an analysis
Add file outputs to an analysis to track the generated outputs, providing a key to identify the output as well as the output file’s path.
Add a file output to an analysis
import mantlebio
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. get( "analysis-id" )
analysis. add_file_output( "my_file_output" , f" { os. getcwd( ) } /some_output.txt" )
Adding a Python string or Boolean output to an analysis
Track string or Boolean outputs by specifying the output key and value.
Add a Python string or Boolean output to an analysis
import mantlebio
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. get( "analysis-id" )
analysis. add_output( "my_string_output" , "some string" )
analysis. add_output( "my_boolean_output" , True )
Creating a Mantle analysis outside the Mantle UI When you use analysis notebooks within the Mantle user interface in combination with the Mantle SDK, you can track and share the executed code in addition to cataloging the inputs and outputs.
You can also create an analysis object outside of Mantle analysis notebooks using the SDK. Some examples of this use case include analysis performed within local Jupyter notebooks, local Python cripts, or a Python interpreter. However, though the analysis and its inputs and outputs will be represented in the lineage graph in the Mantle UI, the code will not be tracked or accesible within the Mantle UI.
Creating an analysis object Note: Local analysis creation does not currently support tracking of notebook code or any other code executed outside of the Mantle UI. For full visibility into the executed code version, using the Mantle UI is recommended.
import mantlebio
mantle = mantlebio. MantleClient( )
analysis = mantle. analysis. create( "My Custom Analysis" )