Skip to content

Instantly share code, notes, and snippets.

View slowkow's full-sized avatar
🐄
moooooo

Kamil Slowikowski slowkow

🐄
moooooo
View GitHub Profile
@slowkow
slowkow / merge_lanes.py
Last active July 27, 2016 13:23
Merge FASTQ files from multiple lanes.
#!/usr/bin/env python
# encoding: utf8
"""
merge_lanes.py
Kamil Slowikowski
July 17, 2015
Broad Technology labs provides sequencing data in a directory structure like
this:
@slowkow
slowkow / toggle-trackpoint.sh
Created July 7, 2015 00:00
Toggle IBM TrackPoint in Ubuntu
#!/usr/bin/env bash
# toggle-trackpoint.sh
set -uoe pipefail
# xinput list
# ⎡ Virtual core pointer id=2 [master pointer (3)]
# ⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
# ⎜ ↳ SynPS/2 Synaptics TouchPad id=14 [slave pointer (2)]
@slowkow
slowkow / refresh-finder.applescript
Last active March 18, 2022 08:17
Refresh Finder when a mounted remote folder fails to update.
(*
Put this script in:
/Users/USERNAME/Library/Scripts/
Download and install FastScripts to assign this script to a keyboard shortcut:
http://www.red-sweater.com/fastscripts/
Source: http://apple.stackexchange.com/a/49546/123845
@slowkow
slowkow / make_aspera_manifest.sh
Created April 24, 2015 20:03
Make a manifest file for Aspera.
#!/usr/bin/env bash
# make_aspera_manifest.sh
# Kamil Slowikowski
#
# Make a manifest file suitable for Aspera.
#
# Example
# -------
#
# Suppose we wish to send a folder full of files called "data". We want
@slowkow
slowkow / sra-paired.sh
Last active April 28, 2023 02:35
Check if an SRA file contains paired-end data.
#!/usr/bin/env bash
# sra-paired.sh
# Kamil Slowikowski
# April 23, 2014
#
# Check if an SRA file contains paired-end sequencing data.
#
# See documentation for the SRA Toolkit:
# http://www.ncbi.nlm.nih.gov/Traces/sra/sra.cgi?view=toolkit_doc&f=fastq-dump
@slowkow
slowkow / pathway_genes.py
Last active September 22, 2022 14:15
Get FASTA Gene Sequences for all Genes in a KEGG Pathway
#!/usr/bin/env python
"""
pathway_genes.py
Kamil Slowikowski
[email protected]
Updated 2021-03-22
Usage
@slowkow
slowkow / pca.R
Last active June 30, 2024 09:54
Perform Principal Components Analysis (PCA) in R
#' Get the variance explained by principal components
#' @param plist A list with class "prcomp" containing: sdev, rotation, x.
variance_explained <- function(plist) {
rotation <- as.data.frame(plist$rotation)
variance <- plist$sdev ^ 2
data.frame(
Component = factor(1:ncol(rotation), levels = 1:ncol(rotation)),
Variance = variance / sum(variance),
CumulativeVariance = ( cumsum(variance) / sum(variance) )
)
@slowkow
slowkow / biosample2tsv.xsl
Last active August 29, 2015 14:13
Transform Biosample XML to TSV.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" />
<!--
Transform biosample XML to TSV.
Usage: xsltproc biosample2tsv.xsl input.xml > output.tsv
-->
<xsl:template match="/">GEO<xsl:text>&#x9;</xsl:text>Title<xsl:text>&#x9;</xsl:text>CellLine<xsl:text>&#x9;</xsl:text>CellType<xsl:text>&#x9;</xsl:text>CdnaMethod<xsl:text>&#10;</xsl:text>
<xsl:for-each select="//BioSample">
@slowkow
slowkow / query_biomart.R
Last active June 1, 2022 13:28
Get symbols (or any other ids) corresponding to Ensembl gene ids
# 1. Install biomart.
source("http://bioconductor.org/biocLite.R")
biocLite("biomaRt")
# 2. Load biomart.
library(biomaRt)
# 3. Get symbols for Ensembl IDs