Skip to content

Instantly share code, notes, and snippets.

View jamestwebber's full-sized avatar

James Webber jamestwebber

View GitHub Profile
@jamestwebber
jamestwebber / qrcard notebook.ipynb
Last active July 15, 2019 13:39
A Jupyter notebook for making qrcodes out of existing images and adding a URL. Fixed to 41x41 (version 6) images. Depends on numpy, scipy, matplotlib, Pillow, and python-qrcode.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jamestwebber
jamestwebber / wilensky.ipynb
Last active June 21, 2017 23:56
A Python Notebook for Wilensky's fairness illusion exercise
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jamestwebber
jamestwebber / nanopore_packer_build.log
Created January 31, 2018 03:20
Log of `PACKER_LOG=1 packer build nanopore.json`
➜ packer-images git:(specops) ✗ PACKER_LOG=1 packer build -force nanopore.json
2018/01/30 19:06:30 [INFO] Packer version: 1.1.0
2018/01/30 19:06:30 Packer Target OS/Arch: darwin amd64
2018/01/30 19:06:30 Built with Go Version: go1.9
2018/01/30 19:06:30 Detected home directory from env var: /Users/james.webber
2018/01/30 19:06:30 Using internal plugin for vmware-iso
2018/01/30 19:06:30 Using internal plugin for vmware-vmx
2018/01/30 19:06:30 Using internal plugin for googlecompute
2018/01/30 19:06:30 Using internal plugin for hyperv-iso
2018/01/30 19:06:30 Using internal plugin for parallels-pvm
@jamestwebber
jamestwebber / pyro_scvi.ipynb
Created September 17, 2018 18:29
the scVI VAE model, but using Pyro-PPL for inference
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jamestwebber
jamestwebber / pyro_logistic_regression.ipynb
Created October 23, 2018 23:41
A iPython notebook showing how to use SVI for logistic regression in Pyro
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jamestwebber
jamestwebber / filter_fastq.py
Created June 28, 2019 21:08
Filters fastq files for a given list of 20bp guide sequences and outputs a count file
#!/usr/bin/env python3
import argparse
import gzip
import itertools
import os
import multiprocessing
from collections import Counter, defaultdict
@jamestwebber
jamestwebber / cupy_dataloader.py
Created October 31, 2020 20:20
How to use a cupy csr_matrix in PyTorch
import torch
# cupy fails to import when there are no GPUs. This check means that the module can
# still be imported in that case, but of course the classes won't work.
if torch.cuda.is_available():
import cupy
from torch.utils.data import DataLoader, Dataset
from torch.utils.dlpack import from_dlpack
@jamestwebber
jamestwebber / par_counter.rs
Created May 14, 2021 22:29
Implementation of ParExtend for a Counter...maybe
use std::collections::LinkedList;
use std::hash::Hash;
use counter::Counter;
use rayon::prelude::*;
#[derive(Default)]
pub struct ParCounter<T: Hash + Eq, N = usize>(Counter<T, N>);
impl<T: Hash + Eq + Clone, N: Clone + Ord> ParCounter<T, N> {
@jamestwebber
jamestwebber / numba_mannwhitney.py
Last active August 21, 2023 16:39
numba-fied, parallelized Mann-Whitney U-test for 2d arrays
import numpy as np
import numba as nb
import scipy.stats
@nb.njit(parallel=True)
def tiecorrect(rankvals):
"""
parallelized version of scipy.stats.tiecorrect