Skip to content

Instantly share code, notes, and snippets.

View alexpreynolds's full-sized avatar
👋
Hello

Alex Reynolds alexpreynolds

👋
Hello
  • Altius Institute for Biomedical Sciences
  • Seattle, WA USA
  • 05:47 (UTC -07:00)
View GitHub Profile
@alexpreynolds
alexpreynolds / sample_uniform_hg38_intervals.sh
Created September 30, 2021 22:27
Draw N uniform random sample intervals of length L from assembly hg38, taking into account chromosome lengths
#!/bin/bash
# set -xe
set -e
declare -r samples_required=${1}
declare -r interval_length=${2}
#
# [hg38]
@alexpreynolds
alexpreynolds / pyranges-mimic.py
Last active February 25, 2021 21:17
Pyranges equivalent via subprocess + BEDOPS bedmap
#!/usr/bin/env python
import sys
import subprocess
import json
a = sys.argv[1]
b = sys.argv[2]
class SetEncoder(json.JSONEncoder):
@alexpreynolds
alexpreynolds / pr2.bed
Created February 25, 2021 21:02
Pyranges equivalent via subprocess + BEDOPS bedmap - pr2.bed
chr1 110 420 pr2-1 300
chr1 450 750 pr2-2 200
chr1 950 1050 pr2-3 300
@alexpreynolds
alexpreynolds / pr1.bed
Created February 25, 2021 21:01
Pyranges equivalent via subprocess + BEDOPS bedmap - pr1.bed
chr1 100 200 pr1-1 100
chr1 300 400 pr1-2 200
chr1 400 500 pr1-3 100
chr1 700 800 pr1-4 250
@alexpreynolds
alexpreynolds / pandas_df_to_tabix_via_subprocess.py
Created February 16, 2021 17:48
Create an indexed tabix file from a Pandas dataframe via subprocess
#!/usr/bin/env python
'''
Create an indexed tabix file from a Pandas dataframe
via temporary intermediate file and subprocess
'''
import os
import io
import pandas as pd
@alexpreynolds
alexpreynolds / pandas_df_to_tabix_via_libraries.py
Last active April 25, 2024 13:26
Create an indexed tabix file from a Pandas dataframe via "pure" Python
#!/usr/bin/env python
'''
Create an indexed tabix file from a Pandas dataframe
via "pure" Python (i.e., no subprocess)
'''
import os
import io
import pandas as pd
@alexpreynolds
alexpreynolds / cmdoptions.c
Last active October 26, 2020 19:48
Growing a C++ vector until a resize triggers a bad_alloc exception
/*
File autogenerated by gengetopt version 2.22.1
generated with the following command:
gengetopt --file-name=cmdoptions
The developers of gengetopt consider the fixed text that goes in all
gengetopt output files to be in the public domain:
we make no copyright claims on it.
*/
@alexpreynolds
alexpreynolds / gist:af2d1b4294cbbede9a49b2e9eb86528d
Last active September 22, 2020 22:38
bigWig to Starch compression ratio and `unstarch --list-json`/`unstarch <chr>` memory usage
BigWig to BedGraph
$ wget -qO- https://www.encodeproject.org/files/ENCFF978IHV/@@download/ENCFF978IHV.bigWig > ENCFF978IHV.bigWig
$ bigWigToBedGraph ENCFF978IHV.bigWig ENCFF978IHV.bigWig.bg
BedGraph to Starch
$ starch --omit-signature ENCFF978IHV.bigWig.bg > ENCFF978IHV.bigWig.bg.starch
Compression ratio
@alexpreynolds
alexpreynolds / multivecTest.json
Created June 12, 2020 19:04
Test of higlass-multivec (master/v0.2.4)
{
"editable" : false,
"zoomFixed" : false,
"trackSourceServers" : [
"/api/v1",
"http://higlass.io/api/v1"
],
"exportViewUrl" : "/api/v1/viewconfs/",
"views" : [
{
@alexpreynolds
alexpreynolds / test3.json
Created June 9, 2020 17:15
Epilogos (horizontal-stacked-bar) test
{
"editable" : false,
"zoomFixed" : false,
"trackSourceServers" : [
"/api/v1",
"http://higlass.io/api/v1"
],
"exportViewUrl" : "/api/v1/viewconfs/",
"views" : [
{