Skip to content

Instantly share code, notes, and snippets.

@const-ae
const-ae / simplified_lemur_algorithm.R
Created January 6, 2025 11:17
Simplified LEMUR algorithm
#' @param p,q two orthonormal matrices of size `N x M` (i.e., `t(p) %*% p == diag(nrow=N)`)
#' that each represent an `M` dimensional subspace in the `N` dimensional gene space.
#'
#' @return the tangent vector to go from point `p` to `q` on the Grassmann manifold
#' represented as an `N x M` dimensional matrix.
grassmann_log <- function(p, q){
n <- nrow(p)
k <- ncol(p)
z <- t(q) %*% p
At <- t(q) - z %*% t(p)
-- Search for supplementary figures and properly resolve links to them
-- Important. You need to flag the refstepcounter commands in LATEX.
-- Please include the following in your preamble
-- % Help with pandoc conversion
-- \newcommand{\arabic}[1]{__||supfiganchor:display||__}
-- \newcommand{\refstepcounter}[1]{__||supfiganchor:increment||__}
-- Bail if we are converting to LaTeX.
if FORMAT:match('latex') then
@const-ae
const-ae / resolve_equation_labels.lua
Last active August 2, 2024 15:08
Pandoc LUA filter to replace equation references with numbers
-- Based on https://github.com/openjournals/inara/blob/f47cfd4e87d5d1afda9db353966b5102f9c941f2/data/filters/resolve-references.lua
-- Bail if we are converting to LaTeX.
if FORMAT:match('latex') then
return {}
end
local nequations = 0
local equation_labels = {}
@const-ae
const-ae / cbind_se.R
Created May 11, 2020 14:06
Combine two SummarizedExperiments / SingleCellExperiments with partially overlapping genes into one. LICENCE: MIT
#' Combine two SummarizedExperiments / SingleCellExperiments with partially overlapping
#' genes into one
#'
#' Note: This ignores all but the first assay
#' Can handle column sparse and standard matrices
cbind_se <- function(se1, se2, assay_fill = 0, colData_fill = NA, rowData_fill = NA, post_fix = c("_1", "_2")){
stopifnot(length(post_fix) == 2)
# Merge assays based on rowNames
if( (is.null(rownames(se1)) || is.null(rownames(se2))) && nrow(se1) != nrow(se2)){
stop("To cbind SummarizedExperiments either rownames are needed or the ",
df <- data.frame(Circulatory=c(32,26,19,16,14,13,11,11),
Mental=c(11,11,18,24,23,24,26,23),
Musculoskeletal=c(17,18,13,16,12,18,20,26),
Cancer=c(10,15,15,14,16,16,14,14))
rownames(df) <- seq(1975,2010,by=5)
df
library(ggplot2)