anhima.loc - Locating variants, samples and genome regions


In [1]:
import numpy as np
np.random.seed(42)
import random
random.seed(1)
import matplotlib.pyplot as plt
%matplotlib inline
import sys
# import anhima
# dev imports
sys.path.insert(0, '..')
%reload_ext autoreload
%autoreload 1
%aimport anhima.loc

In [2]:
# simulate non-uniform variant positions
n_variants = 1000
p = 0
pos = []
for i in range(n_variants):
    gap = int(np.abs(np.cos(i/100))*100)
    p += gap
    pos.append(p)
pos = np.array(pos)

In [3]:
# plot variant locations
anhima.loc.plot_variant_locator(pos, step=10);



In [4]:
# plot variant locations with y axis inverted
anhima.loc.plot_variant_locator(pos, step=10, flip=True);



In [5]:
loc = anhima.loc.locate_interval(pos, 11000, 20000)
loc


Out[5]:
slice(204, 315, None)

In [6]:
pos[loc.start-1], pos[loc.start]


Out[6]:
(10999, 11044)

In [7]:
pos[loc.stop-1], pos[loc.stop]


Out[7]:
(19918, 20017)

In [8]:
# plot variant counts
anhima.loc.plot_windowed_variant_counts(pos, window_size=1000);



In [9]:
# plot variant counts
anhima.loc.plot_windowed_variant_counts(pos, window_size=5000);



In [10]:
# plot variant density
anhima.loc.plot_windowed_variant_density(pos, window_size=1000);



In [11]:
# plot variant density
anhima.loc.plot_windowed_variant_density(pos, window_size=5000);



In [12]: