Skip to content

Instantly share code, notes, and snippets.

@daler
daler / parse_orthoxml.py
Last active November 29, 2024 23:01
Parse orthoXML into TSV files
#!/usr/bin/env python
"""
Expand orthogroups from an orthoXML file into TSV, and then only select the
easy cases where there is exactly one gene from each species. The full TSV is
output as well.
Currently assumes *pairwise* files.
Output will have suffixes _full.tsv and _pair.tsv, with full and only genes in
@daler
daler / example.py
Created February 24, 2024 19:04
LA API
"""
Requirements:
- access to an external, publicly-accessible server. The user
authentication will redirect here. You can tail the logs on that server to
see the response.
- Access Key ID (akid) from LabArchives support. This requires a ticket and
approval from whoever is running the LabArchives instance. It is expected
that this is passed as an env var, LA_AKID.
@daler
daler / setup.md
Created September 7, 2017 18:11

On an m4.10xlarge:

sudo apt-get install imagemagick xorg libx11-dev libglu1-mesa-dev htop

Then fire up R as root, and run the following (note that biocLite nowadays will install from CRAN which is pretty nice!)

@daler
daler / ex.py
Created August 9, 2017 14:17
bedtools issue 553
from __future__ import print_function
import pybedtools
import subprocess as sp
print('pbt:', pybedtools.__version__)
pybedtools.debug_mode(True)
print(
sp.check_output(['which', 'bedtools'], universal_newlines=True).strip(),
'(',
sp.check_output(['bedtools', '--version'], universal_newlines=True).strip(),
@daler
daler / report.tsv
Last active January 13, 2017 17:13
example bioconda-recipes lint report
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 14 columns, instead of 2 in line 6.
recipe check info already_in_bioconda bat_file exists_in_channels fix missing_hash missing_home missing_license missing_summary no_tests parse_error uses_git_url
recipes/multiqc-bcbio missing_hash "{'fix': 'add md5, sha1, or sha256 hash to ""source"" section', 'missing_hash': True}" "add md5, sha1, or sha256 hash to ""source"" section" True
recipes/multiqc-bcbio uses_git_url {'fix': 'use tarballs whenever possible', 'uses_git_url': True} use tarballs whenever possible True
recipes/moreutils missing_hash "{'fix': 'add md5, sha1, or sha256 hash to ""source"" section', 'missing_hash': True}" "add md5, sha1, or sha256 hash to ""source"" section" True
recipes/vt missing_hash "{'fix': 'add md5, sha1, or sha256 hash to ""source"" section', 'missing_hash': True}" "add md5, sha1, or sha256 hash to ""source"" section" True
recipes/bcdoc in_other_channels {'exists_in_channels': {'conda-forge'}, 'fix': 'consider deprecating'} {'conda-forge'} consider deprecating
recipes/bcdoc
@daler
daler / binary-heatmap-inspect.py
Created November 1, 2016 18:55
toy examples to show how multiintersect works
"""
Run the script to see example output.
Modify the features in a, b, and c to see how they affect the output
pybedtools.contrib.plotting.BinaryHeatmap uses the "cluster" method,
but unclustered and naive merge versions are shown as well.
"""
import numpy as np
@daler
daler / README.md
Last active October 5, 2016 16:17
FET demo

Shiny app for exploring Fisher's exact tests.

See a running demo at https://daler.shinyapps.io/lcdb_fet/

Run locally with the following command in this directory:

Rscript -e "shiny::runApp()"
#!/usr/bin/env python
# Install into new environment and activate it before running this script:
#
# conda create -n biostars-212519 python=3 requests numpy pandas
# source activate biostars-212519
# python identify_encode_controls.py
import pandas
import numpy as np
# Example for https://www.biostars.org/p/193145
import pybedtools
import pysam
# Use an example BAM file included with pybedtools
fn = pybedtools.example_filename('x.bam')
bam = pysam.Samfile(fn, 'r')
# Filter reads using pysam. Since all aspects of the SAM-format read
@daler
daler / README.md
Last active September 27, 2016 17:25
binary heatmap demo

Setup

Using bioconda, you can install everything you need for this example with

conda install --channel bioconda pybedtools bedtools htslib matplotlib 

Run