Skip to content

Instantly share code, notes, and snippets.

View mmore500's full-sized avatar

Matthew Andres Moreno mmore500

View GitHub Profile
@mmore500
mmore500 / hstrat_ping_demo.ipynb
Last active January 27, 2024 21:18
hstrat_ping_demo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mmore500
mmore500 / reconstruction-quality-experiment.ipynb
Last active February 1, 2024 17:24
reconstruction-quality-experiment.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mmore500
mmore500 / example-rain.py
Created December 27, 2023 08:31
Code for outset Rain Example
from datetime import datetime, timedelta
import itertools as it
import typing
from matplotlib import pyplot as plt
from matplotlib import text as mpl_text
import numpy as np
import outset as otst
import opytional as opyt
import pandas as pd
@mmore500
mmore500 / .gitattributes
Last active December 9, 2023 22:38
Scheme to trim trailing whitespace from diffs via git filter
* text eol=lf filter=cleanWhitespace
@mmore500
mmore500 / install.sh
Last active November 15, 2023 22:10
gcloud R packages install
mkdir -p ~/.cloudshell/
touch ~/.cloudshell/no-apt-get-warning
sudo apt-get update -y
sudo apt-get install -y aptitude
sudo aptitude install -y libgdal-dev libproj-dev r-base
sudo Rscript -e "install.packages(c('codetools', 'dplyr', 'gen3sis', 'gdistance', 'ggplot2', 'Matrix', 'raster', 'rgdal'))"
def _estimate_rank_of_mrca_between_unbiased(
first: HereditaryStratigraphicColumn,
second: HereditaryStratigraphicColumn,
) -> typing.Optional[float]:
ranks_of_retained_commonality_between = [
*iter_ranks_of_retained_commonality_between_generic(first, second)
]
if not ranks_of_retained_commonality_between:
return None
@mmore500
mmore500 / _DecantingPhyloTracker.py
Created February 5, 2023 07:09
DecantingPhyloTracker in-progress
import typing
import numpy as np
import pandas as pd
from ..._auxiliary_lib import indices_of_unique
from ._compile_phylogeny_from_lineage_iters import (
compile_phylogeny_from_lineage_iters,
)
@mmore500
mmore500 / _PerfectBacktrackHandleNative.cpp
Created January 14, 2023 08:18
_PerfectBacktrackHandleNative.cpp
// cppimport
#include <memory>
#include <pybind11/pybind11.h>
namespace py = pybind11;
struct PerfectBacktrackHandleNative {
py::object parent;
@mmore500
mmore500 / _PerfectBacktrackDatabase.py
Created January 10, 2023 09:36
backtrack database
import collections
import typing
class PerfectBacktrackDatabase:
"""Breadcrumb for perfectly backtracking a phylogenetic chain of descent.
Because only backwards references are held, Python garbage collection takes
care of pruning away extinct lineages.
"""
arr = pop_df.to_numpy()
split = np.split(
arr[:, 2],
np.unique(arr[:, [0, 1]], axis=0, return_index=True)[1][1:],
)
pos = 0
for group in split:
# minimizing operations on group_df gives >50% speedup
genome_lookup = group
tournament_rosters = np.random.randint(