Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • eb7458b
  • /
  • doc
  • /
  • plot_arrays.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:f09e470c79d11f6b8cef809e7d4278591d60cc63
directory badge
swh:1:dir:c8ef07c00e7373423df616cd6413d19f019d1bf3

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
plot_arrays.py
# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.4.0
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# +
import numpy as np 
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import matplotlib as mpl
import pandas as pd

import os
import sys
sys.path.append('../src/')
from plotting import GeoDistPlot, plot_multiple_geodist

# %matplotlib inline

# +
# Plotting preferences
plt.rcParams['font.sans-serif'] = "Arial"
plt.rcParams['figure.facecolor'] = "w"
plt.rcParams['figure.autolayout'] = True

from mpl_toolkits.axes_grid1 import make_axes_locatable

# Deboxing a particular axis
def debox(ax):
    ax.spines['right'].set_visible(False)
    ax.spines['top'].set_visible(False)

figdir = '../plots/figure6/'
os.makedirs(figdir, exist_ok=True)
# -

# # Plotting the Array Figure (MAF 5% Boundary)

# +
# %%time
# Relevant Parameters
array_file_lists = ["Affy6", 
                    "HumanOrigins", 
                    "OmniExpress", 
                    "Omni25Exome", 
                    "MEGA"]

pops_str = 'superpops_amended2'
# popfile = '../../../params/poplists/%s_panel.txt' % pops_str
ncat_str = '3x'
prefix = 'new_1kg_nyc_hg38_filt'
cmap_name = 'Blues'
n_arrays = len(array_file_lists)

# Storing GeoDist Objects
array_geodists = []

for i in range(n_arrays):
    subset = array_file_lists[i]
    input_file = '../data/geodist/counts/subsets/%s/%s_%s_%s.geodist_cnt.txt.gz' % (subset, prefix, pops_str, ncat_str)
    cur_geodist = GeoDistPlot()
    cur_geodist._add_text_data(input_file, filt_unobserved=True)
    cur_geodist._add_poplabels_manual(np.array(['AFR','EUR','SAS','EAS','AMR']))
    cur_geodist._filter_data(max_freq=0.005)
    cur_geodist._add_cmap(cmap_name, str_labels=['u','R','C'])
    cur_geodist.fontsize = 8
    array_geodists.append(cur_geodist)
# -

f, axs = plot_multiple_geodist(array_geodists, array_file_lists, ylabel = 'Cumulative fraction of 1000G variants', hwidth=0.3) 
plt.savefig(figdir + 'fig6.pdf', bbox_inches='tight')

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API