Skip to content

Instantly share code, notes, and snippets.

View slowkow's full-sized avatar
🐄
moooooo

Kamil Slowikowski slowkow

🐄
moooooo
View GitHub Profile
flatten_points <- function(plot, width = 10, height = 5, dpi = 200) {
is_geom_point <- sapply(plot$layers, function(layer) {
"GeomPoint" %in% class(layer$geom)
})
plot_flat <- plot + ggplot2::theme_void()
plot_vector <- plot
plot_flat$layers <- plot$layers[is_geom_point]
plot_vector$layers <- plot$layers[!is_geom_point]
@slowkow
slowkow / coin-flip.R
Created October 26, 2018 18:09
Simulate lots of independent coin flip games, or just one long game.
# Inspired by Ole Peters: https://youtu.be/LGqOH3sYmQA
# Play the coin flip game for n rounds.
# Win 50% of your holdings if you get heads
# Lose 40% of your holdings if you get tails
# Keep flipping for n rounds
play <- function(n) 100 * cumprod(ifelse(runif(n) > 0.5, 1.5, 0.6))
n_plays <- 1e4
@article{slowikowski2014snpsea,
title={SNPsea: an algorithm to identify cell types, tissues and pathways affected by risk loci},
author={Slowikowski, Kamil and Hu, Xinli and Raychaudhuri, Soumya},
journal={Bioinformatics},
volume={30},
number={17},
pages={2496--2497},
year={2014},
publisher={Oxford University Press}
}
@slowkow
slowkow / pdf-montage.sh
Last active September 6, 2018 01:24
Take a PDF and create a PNG with a montage of thumbnails of each page.
#!/usr/bin/env bash
# pdf-montage.sh
#
# Take a PDF and create a PNG with a montage of thumbnails of each page.
#
# Example PDF:
# https://academic.oup.com/bioinformatics/article-pdf/30/17/2496/17148439/btu326.pdf
#
# Example montage:
# https://i.imgur.com/nGn989z.png

Keybase proof

I hereby claim:

  • I am slowkow on github.
  • I am slowkow (https://keybase.io/slowkow) on keybase.
  • I have a public key ASBe4ASDYY-VM4a2XfUM6DYlQBo8eEaiYOyLYBy9Hf4-5wo

To claim this, I am signing this object:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.1/pako.min.js"></script>
</head>
<body>
<form id="my-form">
<input type="file" name="file">
@slowkow
slowkow / remove-emoji.py
Created July 19, 2018 14:10
Remove all traces of emoji from a text file.
#!/usr/bin/env python
"""
Remove emoji from a text file and print it to stdout.
Usage
-----
python remove-emoji.py input.txt > output.txt
"""
@slowkow
slowkow / glib-problem.md
Created July 5, 2018 15:03
version `GLIBCXX_3.4.20' not found

Problem

** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
@slowkow
slowkow / slopegraph.ipynb
Last active June 15, 2018 00:36
Make a slopegraph in R with ggplot2 and ggrepel
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@slowkow
slowkow / lollipop.ipynb
Created June 14, 2018 14:45
Make a lollipop plot in R with ggplot2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.