Skip to content

Instantly share code, notes, and snippets.

View alinaselega's full-sized avatar

Alina Selega alinaselega

View GitHub Profile
@alinaselega
alinaselega / gridspec_example.py
Created January 19, 2024 21:18
Example of how to make a plt plot with multiple aligned subplots
# from https://matplotlib.org/stable/gallery/subplots_axes_and_figures/gridspec_multicolumn.html
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
def format_axes(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, "ax%d" % (i+1), va="center", ha="center")
@alinaselega
alinaselega / seurat-to-anndata.R
Last active December 14, 2023 15:26
Convert Seurat object/SingleCellExperiment to AnnData in R
# run R in an activated Python environment that has AnnData installed
library(Seurat)
library(reticulate)
# check that the environment is found
reticulate::py_discover_config()
file_rds <- readRDS("file.rds")
# Option 1
# file.rds is an SCE object
@alinaselega
alinaselega / make-fake-clusters.ipynb
Created February 10, 2022 18:12
Notebook for making a clustering illustration (adapted from sklearn)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alinaselega
alinaselega / bounded_param.ipynb
Last active August 16, 2021 20:15
This notebook demonstrates the steps of using a scaled translated sigmoid to bound a free parameter to an interval [a,b].
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alinaselega
alinaselega / Lab_Meeting_Demo_June.pdf
Last active June 30, 2021 17:07
Slides for the demo of nbdev for Campbell lab meeting in June 2021.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@alinaselega
alinaselega / remove_last_commit.md
Created June 28, 2021 14:37
How to remove the last wrong commit from history

If you accidentally pushed a wrong file to the remote, you can remove the file and the erroneous commit from the history with the following. Identify the last good commit you want to go to and copy its SHA. (Make sure you have no unsaved changes in your local repo as they will be lost.) Then do:

git reset --hard SHA_ID
git push -f

The first command resets HEAD to the commit SHA_ID. The second one force pushes the new state to the remote.

@alinaselega
alinaselega / print_model_params.py
Created April 6, 2021 17:15
Code snippet to print model parameters after training
for param_name, param in model.named_parameters():
print(f'Parameter name: {param_name:42} value = {param.item():.4f}')
@alinaselega
alinaselega / ssh_pi_to_laptop.md
Last active April 6, 2021 14:34
A short guide to ssh connection from one machine to another on a local network.

I keep forgetting how to debug ssh connection problems from one local machine to another (in my case, my laptop). This short guide lists the steps to successfully connect but it assumes that the pre-requisite requirements are already satisfied.

Specifically, both machines need to be on a local network managed by ZeroTier One. Note that after a restart, the zerotier application needs to be started again on a Windows machine. (I need to double check whether zerotier starts automatically on my Linux machine but I didn't have to start it again just now.) The ssh keys need to be set up on both machines accordingly. Both of my machines have tmux installed and the "remote" local machine (the one I am connecting to i.e. my laptop) has a host nickname (remote-host below) set up in .ssh/config on my "local" local machine.

@alinaselega
alinaselega / bash-commands.md
Last active March 10, 2021 21:44
Gist with bash commands to display, count, and copy files.

Some useful commands for manipulating files so I don't have to search for these.

Count the number of files in a directory name:

ls name | wc -l

Display top n sorted filenames:

@alinaselega
alinaselega / gap_stat_tutorial.ipynb
Created February 26, 2021 20:55
Tutorial on using the `gap_statistic` package (https://github.com/milesgranger/gap_statistic).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.