Skip to content

Instantly share code, notes, and snippets.

@jelber2
jelber2 / shredBAM.jl
Last active March 11, 2024 13:09
Shred alignments in a BAM file (output is a SAM file without header) to make long read alignments into short-read-like
# previous versions allowed to generate directly from BAM, but there seemed to have been some troubles
# between versions of XAM, so this version is working so far for its intended purpose on https://github.com/brendanofallon/jovian
# also, this version is rather fast
#
#
# note: ignores quality scores at the moment - fixed in revision#4
# note2: outputs to STDOUT a SAM file without a header
# tested with julialang v1.10.2 and XAM v0.4.0
# $ julia shredBAM.jl input.bam 300 > test.sam.noheader
#
@adamkucharski
adamkucharski / epinow2_infection.R
Last active February 26, 2024 14:18
Simulated infection recovery
# Example code for simulation recovery of infection dynamics from deaths for COVID -----------------------------------------
# Load libraries:
# install.packages("EpiNow2", repos = "https://epiforecasts.r-universe.dev")
library(EpiNow2)
# Simulate data and delays -----------------------------------------
# Simulate infections with a sharp drop
@adamkucharski
adamkucharski / 2024_01_delay_PCR.R
Last active January 2, 2024 12:26
Illustrative plots for PCR positivity
# - - - - - - - - - - - - - - - - - - - - - - -
# Code by Adam Kucharski to accompany post 'Counting current COVID infections' (2nd Jan 2024)
# Post is available at: https://kucharski.substack.com
# Code in this file is shared under an MIT license (https://opensource.org/license/mit/)
# - - - - - - - - - - - - - - - - - - - - - - -
# Load libraries
library(dplyr)
library(readr)
@avonmoll
avonmoll / .gitignore
Last active February 5, 2024 16:33
Categorized Bibliography in Typst
library.yaml
@jonocarroll
jonocarroll / rowmin.rs
Created November 17, 2023 00:34
rextendr Rust/R function to calculate the rowMins of a matrix (no NA processing)
library(rextendr)
rust_function("
fn rowmin(m: RMatrix::<i32>) -> Vec<i32> {
// convert to an ndarray
let matrix = <ArrayView2<i32>>::from_robj(&m).unwrap();
// store results
let mut min_values = Vec::with_capacity(matrix.len());
@beeb
beeb / nomenclature.typ
Created June 19, 2023 13:06
Product nomenclature template for Typst
#let segments = (
(nomenclature: "4", title: "Refrigerant Type", description: [4 = R-410A \ 2 = R22], separator: ""),
(nomenclature: "TE", title: "Application", description: [TE = Fully Convertible \ TG = Semi Convertible], separator: "-"),
(nomenclature: "E", title: "Product Family", description: [E = Leadership -- Variable Speed \ P = Leadership], separator: "-"),
)
#let nomenclature(
segments: ((nomenclature: "A", title: "Foo", description: [Bar], separator: "-"))
) = {
place(top + left, [#box()#label("margins")]) // get top + left margins dynamically
@te-lang-wakker
te-lang-wakker / info-box.typ
Last active March 18, 2024 09:19
Titled & stacking textbox for Typst
// todo: key this by the provided label or just use dependency injection
#let this-counter = counter("info-box")
#let info-box(
title: none,
sections: none,
label: none,
caption: none,
radius: 3pt,
inset: 16pt,
@BlueskyFR
BlueskyFR / glossary.typ
Last active March 25, 2024 14:26
A glossary for Typst that uses native functions!
// Glossary code by Hugo Cartigny (BlueskyFR) 🍉
#let glossary(indent-defs: false, doc) = {
// ✨ The glossary displays its items using level 99 headings
let glossary = state("wow", (:))
// Hide the numbering for level 99 titles
show heading.where(level: 99): it => text(weight: "regular", it.body)
let page-refs-color = rgb("#7630EA")
@dlakelan
dlakelan / PriorOnFuncs.jl
Created January 2, 2023 03:29
Path Integral Approach For Functional Priors
using Pkg
Pkg.activate(".")
Pkg.add(["Turing","Distributions","ApproxFun","QuadGK","StatsPlots","LinearAlgebra","DataFrames"])
using Turing, Distributions, ApproxFun, QuadGK, StatsPlots, LinearAlgebra, DataFrames
# a prior over functions that go up then come down... First let's see how ApproxFun works
Random.set_global_seed!(123456)
f = Fun(Chebyshev(Interval(0..100)),randn(12))
@strengejacke
strengejacke / .lintr
Last active July 26, 2024 10:49
VS Code setup for R
// save to windows-user directory
linters: with_defaults(object_name_linter = NULL,
object_length_linter(50),
commented_code_linter = NULL,
object_usage_linter = NULL,
line_length_linter(120),
cyclocomp_linter = cyclocomp_linter(50))