Skip to content

Instantly share code, notes, and snippets.

@mkweskin
mkweskin / keep-longest.py
Last active March 15, 2019 14:10
Keep longest sequence when there are duplicate descriptions in FASTA file: Reads a FASTA file and if >1 sequence has the same description line, it only keeps the longest sequence. It outputs all the sequencs to stdout when complete.
#!/usr/bin/python
"""
Reads a FASTA file and if >1 sequence has the same description line,
it only keeps the longest sequence. It outputs all the sequencs to stdout
when complete.
"""
@wflynny
wflynny / scanpy_cluster_proportions.py
Last active October 13, 2023 17:42
Stacked barplot of scRNA-seq cluster proportions per sample
import scanpy.api as sc
import matplotlib.pyplot as plt
import seaborn as sns
def get_cluster_proportions(adata,
cluster_key="cluster_final",
sample_key="replicate",
drop_values=None):
"""
Input
@vidboda
vidboda / addchr2vcf.sh
Created April 8, 2019 11:06
add chr to a vcf file
zcat file1.vcf.gz | awk -F"\t" '{if ($0 !~ /^#/) {print "chr"$0} else{print $0}}' | bgzip -c >file1chr.vcf.gz
@timedreamer
timedreamer / save_pheatmap_pdf.R
Created January 7, 2021 22:18
Save pheatmap figure into pdf
# An R function to save pheatmap figure into pdf
# This was copied from Stackflow: https://stackoverflow.com/questions/43051525/how-to-draw-pheatmap-plot-to-screen-and-also-save-to-file
save_pheatmap_pdf <- function(x, filename, width=7, height=7) {
stopifnot(!missing(x))
stopifnot(!missing(filename))
pdf(filename, width=width, height=height)
grid::grid.newpage()
grid::grid.draw(x$gtable)