Skip to content

Instantly share code, notes, and snippets.

View mfansler's full-sized avatar
⚙️

Mervin Fansler mfansler

⚙️
View GitHub Profile
@mfansler
mfansler / test.mantel.R
Created January 11, 2018 00:46
Implements Mantel's chi-square test for ordinal categorical data
test.mantel <- function (counts, rowScores = NULL, colScores = NULL) {
## This implements an ordinal chi-square test following Mantel, 1963,
## as described in Agresti, 2007, section 2.5.1 "Linear Trend Alternative to
## Independence"
METHOD <- "Mantel's Ordinal Chi-Square Test"
DNAME = deparse(substitute(counts))
n = sum(counts) # total obs
if (n < 30)
@mfansler
mfansler / index-gtf.sh
Last active June 5, 2024 17:51
GTF file compressed indexing for IGV compatibility
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo -e "Incorrect number of parameters! Usage:\n index-gtf.sh <file.gtf(.gz)>" >&2
exit 1
fi
gtf="$1"
if [[ $gtf =~ \.gz$ ]]; then
@mfansler
mfansler / removeGENCODEmRNA_end_NF.sh
Created April 20, 2019 21:54
Remove GENCODE transcripts missing 3' ends
gzip -cd gencode.vM19.annotation.gtf.gz |
awk '$0 !~ /mRNA_end_NF/' |
sort -k1,1 -k4,4n |
bgzip -@4 > gencode.vM19.mRNA_end_found.gtf.gz
tabix gencode.vM19.mRNA_end_found.gtf.gz
#!/usr/bin/env bash
# Example Usage
# ./extract_10X_cell.sh possorted_genome_bam.bam GCCAAATTCACATACG | samtools view -b > cell.bam
#
# Compare with 10X post:
# https://kb.10xgenomics.com/hc/en-us/articles/360022448251-Is-there-way-to-filter-the-BAM-file-produced-by-10x-pipelines-with-a-list-of-barcodes-
if [ "$#" -ne 2 ]; then
echo -e "Incorrect number of parameters! Usage:\n extract_10X_cell.sh <file.bam> <cell_bx>" >&2
@mfansler
mfansler / nesting-example.R
Last active May 10, 2019 02:43
Using tidyverse nesting to unpack a vector of results into a long-format tibble
library(tidyverse)
# values at which to evaluate
# this can be changed arbitrarily
x <- c(1,2,3)
# evaluate y's for every condition and output a long format table
df <- expand.grid(coef=c(1,2), pow=c(1,2,3)) %>%
group_by(coef, pow) %>%
mutate(y=map2(coef, pow, ~ tibble(x=x, y=.x*x^.y))) %>%
@mfansler
mfansler / genewalk-latest.yaml
Last active September 7, 2019 16:42
Minimal Conda Environment for `genewalk`
name: genewalk
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- pandas
- networkx>=2.1
- gensim
- goatools
@mfansler
mfansler / kallisto-build.yaml
Last active October 6, 2020 00:27
Conda Environment for Building Kallisto
name: kallisto-build
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- autoconf
- automake
- hdf5
- make
@mfansler
mfansler / bamfilter_oneliners.md
Last active June 23, 2020 18:55 — forked from davfre/bamfilter_oneliners.md
SAM and BAM filtering oneliners
@mfansler
mfansler / list_export_to_yaml.awk
Last active November 30, 2023 20:18
Convert `conda list` output to YAML
#!/usr/bin/env awk -f
#' Author: Mervin Fansler
#' GitHub: @mfansler
#' License: MIT
#'
#' Basic usage
#' $ conda list --export | awk -f list_export_to_yaml.awk
#'
#' Omitting builds with 'no_builds'
#' $ conda list --export | awk -v no_builds=1 -f list_export_to_yaml.awk
@mfansler
mfansler / so-seurat-full.yaml
Last active September 22, 2020 20:03
Seurat install on OSX-64
name: so-seurat
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- _r-mutex=1.0.1=anacondar_1
- bwidget=1.9.14=0
- bzip2=1.0.8=haf1e3a3_3
- c-ares=1.16.1=haf1e3a3_3