Skip to content

Instantly share code, notes, and snippets.

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)
@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 ",