Skip to content

Instantly share code, notes, and snippets.

import scanpy as sc
import pandas as pd
data = pd.read_csv('path_to_file.csv')
feature_annotations = pd.read_csv('path_to_annotations.csv')
# Make sure samples are rows and features are columns. if not data = data.T
adata = sc.AnnData(data, obs=sample_names, var=feature_annotations)
sc.pp.pca(adata, n_comps=10)
import os
import numpy as np
import scipy as sp
import pandas as pd
import scanpy as sc
import scprocessing.pipeline as scpipe
import scprocessing.preprocessing as scpp
import scprocessing.preprocessing.Svensson2019 as Svensson2019
import scprocessing.plotting.anndata as scpl
import dewakss.decomposition as dede
@Xparx
Xparx / grouped_and_clustered_heatmap.py
Created November 14, 2018 04:00
Minor hack to get clustered grouped heatmap
import scanpy.api as _sc
import scanpy.plotting as _scp
import seaborn as _sns
import numpy as _np
import matplotlib.pyplot as plt
def clustered_heatmap(data, var_names=None, groupby=None, figsize=(12, 6), cluster=True, use_raw=None, log=False, num_categories=7, cbar=False, vmin=None, vmax=None, **kwds):
from anndata import AnnData
@Xparx
Xparx / SBW2015_word_cloud.R
Last active July 5, 2016 20:19
Word cloud creation for SBW 2015 abstract book.
library(tm)
library(wordcloud)
library(memoise)
text_file <- 'SBW2015_book.txt'
# Using "memoise" to automatically cache the results
text <- readLines(sprintf("./%s", text_file), encoding="UTF-8")
text <- stemDocument(text) # doesn't seem to do anything
@Xparx
Xparx / change-theme-on-time.el
Created September 5, 2015 22:48
Load emacs theme based on time when new frame is spawned
(defun change-theme-on-time ()
(destructuring-bind (sec min h m year junk junk junk junk) (decode-time (current-time)))
(if (or (> (string-to-number (format-time-string "%H" (current-time))) 18)
(< (string-to-number (format-time-string "%H" (current-time))) 9))
(unless custom-enabled-themes (load-theme 'my-theme t)) (disable-theme custom-enabled-themes)))
(add-hook 'before-make-frame-hook 'change-theme-on-time)