<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction
This notebook shows how to use the Data API to plot the features in a genome. After initialization, this is broken into just a few high-level steps
Step1:  Get genomes from workspace 654
Step2:  Get feature positions in one of the genomes
Step3:  Plot the features
A 'stripplot' shows each feature as a dot, with the X coordinate being the start position in the sequence and on the Y axis is each type of feature in the dataset (sorted, by default, alphabetically). This kind of plot doesn't help with any detailed analysis, but it provides a good simple overview of the feature data.
Because we did %matplotlib notebook to load matplotlib, we automatically get zooming and panning. In essence, this makes our plat a mini-genome-browser with "tracks" for each feature.
<ASSISTANT_TASK:>
Python Code:
%matplotlib notebook
import seaborn as sns
import os
from doekbase import data_api
from doekbase.data_api import display
b = data_api.browse(1013)
g = b['kb|g.1'].object
g
Explanation: Introduction
This notebook shows how to use the Data API to plot the features in a genome. After initialization, this is broken into just a few high-level steps:
* Load up a workspace (namespace for the data, but also each narrative has its own workspace)
* Find genomes in the workspace
* Select one of those genomes
* Get the feature positions in the selected genome
* Plot the feature positions
Initialize
End of explanation
# Get a "browser" for the workspace
b = data_api.browse(654)
# Get API object for 2nd genome (index 1)
g1 = b.filter(type_re='KBaseGenomesCondensedPrototypeV2.GenomeAnnotation-.*')[1].object
display.Organism(g1)
Explanation: Get genomes from workspace 654
End of explanation
f = display.FeaturePositions(g1)
reload(qgrid)
qgrid.nbinstall()
import pandas as pd
f2 = pd.DataFrame({'foo': (1,2,3), 'bar': {'a', 'b', 'c'}})
qgrid.show_grid(f2)
Explanation: Get feature positions in one of the genomes
End of explanation
import numpy as np
import pickle
f = pickle.load(open('featurepos'))
sns.stripplot(x='start', y='type', marker='.', size=10, data=f)
max(f['len'])
f.to_pickle('featurepos')
Explanation: Plot the features
A 'stripplot' shows each feature as a dot, with the X coordinate being the start position in the sequence and on the Y axis is each type of feature in the dataset (sorted, by default, alphabetically). This kind of plot doesn't help with any detailed analysis, but it provides a good simple overview of the feature data.
Because we did %matplotlib notebook to load matplotlib, we automatically get zooming and panning. In essence, this makes our plat a mini-genome-browser with "tracks" for each feature.
End of explanation
<END_TASK>