Cookies 🍪

We use cookies to ensure you the best possible experience when using BioLib. To read our privacy policy and configure what cookies are set, click on cookie settings below.

Creating Your First Application (Video Tutorial)


This tutorial shows you how to build your first application on BioLib. It is designed as a video tutorial, so you should follow the steps in this video.

BioLib Video Tutorial

You do not need to write any code in this tutorial.

All the code you need will be supplied for you to copy and paste.

In total the tutorial takes 15 minutes to complete - so you will probably be able to make it in 12.

Before you start:

  1. Open the tutorial video in a separate tab - it will guide you

through each of the subsequent steps.

  1. You need to be signed in to your BioLib account to build applications. If you do not have an account yet, you can create a free account here.

The mission:

The goal in this tutorial is to turn a Python 3 script for plotting heat-maps into a user-friendly application that runs directly in the browser, requires no coding by the end-user to use, and can be used by scientist from anywhere in the world without them having to worry about dependencies.

Step 1 - Create Application using Python Template

To-do list:

  • Press Create Application (Remember, you need to be signed in!)
  • Choose the Python template

Continue to Step 2.

Step 2 - Add Code

To-do list:

  • Add your code (hint: just copy-paste the code from below) and set Module settings
  • Under advanced settings, set output to Markdown

The Code (copy and paste this)

Simply, copy-paste the code following into the file under source files. In the Modules settings, the bl-python3: executor should already have been autoselected under the type option for the main module.

import pandas as pd
import seaborn as sns;
import matplotlib.pyplot as plt
import argparse

# utility function to parse csv from binary on BioLib

def format_data_from_csv_buffer(infile, index=0, separator=','):
    data = pd.read_table(infile, sep=separator)
    data.rename(columns={data.columns[index]: "sample"}, inplace=True) # Change the labels column name
    labels = data.pop("sample")
    return data, labels

def generate_heatmap(data, labels, color):
    heatmap_object = sns.heatmap(data, cmap=color, yticklabels=labels, cbar_kws={'label': 'Expression level'})

# Load input parameter, or use default if none provided
# index of the labels column in the file
parser = argparse.ArgumentParser()
parser.add_argument('--in', dest='infile')
parser.add_argument('--index', dest='index')
parser.add_argument('--separator', dest='separator')
parser.add_argument('--color', dest='color', default='magma')
args = parser.parse_args()
color = args.color

# Load input data
data,labels = format_data_from_csv_buffer(args.infile, index=int(args.index), separator=args.separator)

# Generate output
generate_heatmap(data, labels, color)

# Produce Markdown
print("![Markdown Picture Alt Text](my_heatmap.png)")

Step 3 Configuring Input Arguments

Next up is configuring the input arguments. This is where you define the options that the end-user of the application will be presented with when running the application, and how their choices or inputs will be passed to your script.

The "in" input argument should be configured like this:

input file BioLib

The "index" input argument should be configured like this:

index input argument BioLib

The "separator" input argument should be configured like this:

separator input argument BioLib tutorial

The "color" input argument should be configured like this:

color scheme argument BioLib tutorial

Step 4 - Description and License

To-do list:

  • Edit the README file and add example input
  • Edit License
  • Change the name of your application under the "App Settings"
  • View the application page

Example data (copy and paste when running your application)


Step 5 - Test, Publish, and Edit

  • Save your application
  • Try running your application
  • Edit, share and update your application

Congratulations, you have now built your first application on BioLib!