Skip to content

Instantly share code, notes, and snippets.

View gregjohnso's full-sized avatar
🏗️
Building

Gregory Johnson gregjohnso

🏗️
Building
View GitHub Profile
@gregjohnso
gregjohnso / setup_ubuntu
Last active May 5, 2017 16:33
Setting up an EC2 instance for nvidia-docker on Ubuntu 16.04
#install ubuntu things
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install -y build-essential libfreetype6-dev libxft-dev libncurses-dev libopenblas-dev gfortran libblas-dev liblapack-dev libatlas-base-dev linux-headers-generic linux-image-extra-virtual unzip unzip wget pkg-config zip g++ zlib1g-dev libcurl3-dev
sudo apt-get install -y vim
sudo apt-get install nvidia-375
# wget http://us.download.nvidia.com/XFree86/Linux-x86_64/375.39/NVIDIA-Linux-x86_64-375.39.run
# sudo chmod ugo+rwx NVIDIA-Linux-x86_64-375.39.run
# sudo ./NVIDIA-Linux-x86_64-375.39.run -a
@gregjohnso
gregjohnso / jupyter_on_compute_node.md
Last active April 26, 2017 18:48 — forked from donovanr/jupyter_on_compute_node.md
access jupyter notebooks running on compute nodes

Port forwarding using ProxyJump and ssh tunnels

  • set up a new host in your ~/.ssh/config file (change rorydm to your own username):
Host tartarus
    HostName n70
    ProxyJump qmaster
    User rorydm
    LocalForward 9999 localhost:9999
function [ cumLatent, score ] = plotPCA3D(data, labels, project, cm_handle)
%Z-scores and plots the first 3 prinicple componenets
%gregory johnson
%gregjohnso@gmail.com
if ~exist('project', 'var') | isempty(project)
project = false;
@gregjohnso
gregjohnso / read_obs.py
Created September 19, 2023 17:59
super quick way to read adata.obs out of a anndata file
from anndata._io import h5ad
import h5py
import pandas as pd
def read_obs(hdf5_path: str) -> pd.DataFrame:
hdf5_file = h5py.File(hdf5_path, 'r')
df_obs = h5ad.read_dataframe(hdf5_file['obs'])
return df_obs
df = read_obs(hdf5_path = "/my/andata/path/file.h5ad")
@gregjohnso
gregjohnso / save_scanpy_fig.py
Last active July 16, 2024 00:52
save scanpy plot with matplotlib
"""From: https://github.com/scverse/scanpy/issues/1508#issuecomment-734657400"""
from matplotlib import pyplot as plt
with plt.rc_context(): # Use this to set figure params like size and dpi
sc.pl.plotting_function(..., show=False)
plt.savefig("path/to/file.extension", bbox_inches="tight")