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 / .Rprofile
Created April 3, 2024 18:38
Default color, fill, and theme settings for ggplot2
# ~/.Rprofile
ggplot2_discrete_pals <- list(
"tol" = c(
"#77AADD", "#EE8866", "#EEDD88", "#FFAABB", "#99DDFF", "#44BB99",
"#BBCC33", "#AAAA00"
),
"okabe" = c(
"#E69F00", "#56B4E9", "#009E73", "#F5C710", "#0072B2", "#D55E00",
"#CC79A7", "#999999", "#000000"
@slowkow
slowkow / find_correlated_genes.R
Created March 12, 2024 16:19
Find the top 10 correlated genes, based on data from ARCHS4
# find_correlated_genes.R
# 2024-03-12
# Kamil Slowikowski
library(arrow) # install.packages("arrow")
# Download correlation from ARCHS4 <https://maayanlab.cloud/archs4/download.html>
# wget https://s3.amazonaws.com/mssm-data/human_correlation_archs4.f
# The file is large:
@slowkow
slowkow / word-reorder-figures.md
Last active May 2, 2023 18:01
How to update figure references after reordering them in Microsoft Word

How to update figure references in Word

Add a new caption in the Figure Legends section of your manuscript:

  • In the menu bar, click Insert > Caption...
  • Type a name like "My great data" — you can always change it later.
  • Click OK
@slowkow
slowkow / circle-montage.md
Created March 21, 2023 22:52
Make a montage of circle-cropped photos

Make a montage of circle-cropped photos

Here are the source files, the masked output folder, and the montage.png output file:

Here are the images in the masked output folder:

@slowkow
slowkow / rotating-3d-mp4.R
Last active October 21, 2024 18:46
Make an animation to visualize millions of points in 3 dimensions.
library(data.table)
library(glue)
library(rgl)
# https://github.com/google/palette.js/blob/master/palette.js
mpn65 <- c(
'#ff0029', '#377eb8', '#66a61e', '#984ea3', '#00d2d5', '#ff7f00', '#af8d00',
'#7f80cd', '#b3e900', '#c42e60', '#a65628', '#f781bf', '#8dd3c7', '#bebada',
'#fb8072', '#80b1d3', '#fdb462', '#fccde5', '#bc80bd', '#ffed6f', '#c4eaff',
'#cf8c00', '#1b9e77', '#d95f02', '#e7298a', '#e6ab02', '#a6761d', '#0097ff',
@slowkow
slowkow / copy-to-google.sh
Created March 23, 2022 15:13
Copy files from Broad to Google
#!/usr/bin/bash
#$ -N MY_JOB_NAME
#$ -o /path/on/broad/server/
#$ -e /path/on/broad/server/
#$ -cwd
#$ -j y
#$ -l h_rt=12:00:00
#$ -pe smp 8 -R y -binding linear:8
#$ -l h_vmem=2G
#
@slowkow
slowkow / plot-umap-experiment.R
Last active August 18, 2024 09:07
UMAP on 30k cells with different values for min_dist and spread
library(uwot)
library(scattermore)
library(foreach)
library(doParallel)
library(data.table)
library(ggplot2)
library(scales)
library(glue)
# This code snippet assumes we have these objects:
@slowkow
slowkow / pay-water-bill.py
Created May 3, 2021 01:32
Pay your water bill in Baltimore City
#!/usr/bin/env python3
# pay-water-bill.py
# 2021-05-02
"""
Pay your water bill in Baltimore City
=====================================
Steps:
@slowkow
slowkow / montage.py
Created December 23, 2020 19:40
Make a montage from a list of PDF files
#!/usr/bin/env python
"""
montage.py
2020-12-23
Kamil Slowikowski
Usage
-----
Write montage.png from a list of PDF files, each panel 500px wide:
@slowkow
slowkow / rsa-example.R
Created October 21, 2020 18:48
A toy example of RSA encryption and decryption
#!/usr/bin/env Rscript
# rsa-example.R
#
# Inspired by Alex Van de Sande
# https://twitter.com/avsa/status/1318672796415819776
last_digit <- function(x) {
x_char <- as.character(x)
as.numeric(substr(x_char, nchar(x_char), nchar(x_char)))
}