Skip to content

Instantly share code, notes, and snippets.

@mtmorgan
mtmorgan / tabula-muris-sensis.R
Last active December 23, 2022 22:00
Tabula muris liver discovery & visualization
##
## setup
##
if (!"BiocManager" %in% rownames(installed.packages()))
install.packages("BiocManager", repository = "https://cran.r-project.org")
BiocManager::install(
## only reinstall if newer version available
c("cellxgenedp", "plotly")
)
@mtmorgan
mtmorgan / hca2021bioc.R
Last active October 6, 2021 12:25
Script used during Human Cell Atlas presentation, 2021-10-06
##
## Preliminiaries: install infrasctructure and required packages
##
## We've got to be using a least R version 4.1
my_R_version <-
numeric_version(paste(R.Version()[c("major", "minor")], collapse = "."))
stopifnot(my_R_version >= "4.1")
options(width=160)
library(dplyr)
## BiocManager::install("Bioconductor/hca")
library(hca)
## projects available in the HCA
projects <- projects()
projects
## a specific project
@mtmorgan
mtmorgan / week-2-demo.R
Last active May 3, 2021 14:40
AnVIL PopUp Workshop week 2 script
if (!"AnVIL" %in% rownames(installed.packages()))
BiocManager::install("AnVIL")
library(AnVIL)
this_workspace = avworkspace()
hca = "featured-workspaces-hca/HCA_Optimus_Pipeline"
thousand_genomes = "anvil-datastorage/1000G-high-coverage-2019"
## AnVIL 'namespace' / 'name' == workspace
@mtmorgan
mtmorgan / AWS_ECS_REST.Rmd
Created January 28, 2021 16:23
AWS ECS REST access
# AWS ECS access via REST
Resources
- [Getting Started with ECS][ECS]
- [REST API][API]
[ECS]: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/getting-started-ecs-ec2.html
[API]: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/Welcome.html
package_dependencies <- tools::package_dependencies
trim <- function(deps, drop) {
lvls = names(deps)
df = data.frame(
pkg = factor(rep(names(deps), lengths(deps)), levels = lvls),
dep = unlist(deps, use.names = FALSE)
)
df = df[!df$dep %in% drop,, drop = FALSE]
split(df$dep, df$pkg)
@mtmorgan
mtmorgan / deps_broken.R
Created June 9, 2020 07:18
Query Bioconductor build report for package dependencies that fail to install, build, or check
library(BiocPkgTools)
library(dplyr)
deps_broken <-
function(
pkg,
repos = BiocManager::repositories(),
version = BiocManager::version()
)
{
@mtmorgan
mtmorgan / obo_graph.R
Last active April 12, 2020 16:20
construct distance between GO nodes from OBO file
obo = readLines("go.obo")
##
## Clean data
##
## blank lines separate different 'groups' in the obo
group <- cumsum(!nzchar(obo))
## keep groups that have the [Term] label
@mtmorgan
mtmorgan / bioc_first_appearance.R
Last active January 27, 2023 16:29
bioc_first_appearance
library(yaml)
library(dplyr)
library(tibble)
library(lubridate)
library(readr)
library(memoise)
get_releases <-
function()
{
@mtmorgan
mtmorgan / f.rda
Last active October 25, 2019 13:48
loud load debug