Skip to content

Instantly share code, notes, and snippets.

View milescsmith's full-sized avatar

Miles Smith milescsmith

View GitHub Profile
@milescsmith
milescsmith / PLINK_sample_extraction_file.md
Created November 5, 2024 16:18
Example file for extracting samples from PLINK files
@milescsmith
milescsmith / example-ruff-formatting.ipynb
Created August 9, 2024 20:39 — forked from jbwhit/example-ruff-formatting.ipynb
Steps to use `ruff` in JupyterLab with the `jupyterlab_code_formatter` plugin.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Auto-start ssh-agent in ZSH
#tips#wsl#zsh#ssh-agent
To auto-start the ssh-agent when using zsh add this snippet to your ~/.zshrc:
if [ $(ps ax | grep "[s]sh-agent" | wc -l) -eq 0 ] ; then
eval $(ssh-agent -s) > /dev/null
if [ "$(ssh-add -l)" = "The agent has no identities." ] ; then
# Auto-add ssh keys to your ssh agent
line-length = 120
target-version = "py310"
[lint]
select = [
"A",
"ARG",
"B",
"C",
"DTZ",
@milescsmith
milescsmith / gist:e97ce2f48b854eacbfe8c761fb7f7b6d
Created October 11, 2023 21:11
transparently open gzipped files in python
import gzip
from functools import partial
from io import StringIO
from mimetypes import guess_type
from pathlib import Path
from typing import Optional, Union
from Bio import bgzf
@milescsmith
milescsmith / renew_certs_for_halo.md
Created June 27, 2023 18:59
Renew ssl certificates for HALO

To renew the certificates for the HALO Link server

  • You first need to find and then kill whatever is currently using port 80

    netstat -ano | findstr :80
    

In the far right column, there should be a 2-4 digit number. Make a note of that.

@milescsmith
milescsmith / tirosh_module_scoring.R
Created July 26, 2022 22:21
function to score modules using the method from Tirosh et. al (2006)
utils::globalVariables("where")
tirosh_score_modules <- function(
expr_obj, # rows == genes, columns == samples
module_list, # named list
breaks = 25, # int
num_ctrls = 100, # int
parallel = FALSE # bool
) {
@milescsmith
milescsmith / install_with_pyenv.md
Created June 20, 2022 03:57
Installing with pyenv in MacOS 12+

SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk MACOSX_DEPLOYMENT_TARGET=12.3 pyenv install 3.9.13

@milescsmith
milescsmith / find_snps_in_all_vcfs.sh
Last active May 6, 2022 20:17
search directory for variant files and find particular snps
#! /usr/bin/bash
find . \
-type f \
\( -name "*.vcf" -o -name "*.vcf.gz" -o -name "*.bcf" \) \
-printf "%f\n" \
-exec \
sh \
-c
"bcftools view \
-H \
@milescsmith
milescsmith / quoted_unquoted_argument.R
Created August 25, 2021 19:15
Handle both quoted and unquoted arguments to an R function
if (is.character(substitute(x))){
y <- rlang::sym(x)
} else {
y <- x
x <- as.character(substitute(x))
}
y <- rlang::enquo(y)