Skip to content

Instantly share code, notes, and snippets.

View LiNk-NY's full-sized avatar

Marcel Ramos LiNk-NY

View GitHub Profile
@LiNk-NY
LiNk-NY / extract_api_calls.R
Last active April 9, 2024 22:20
Analyze static code to see which API endpoints are used
## BiocManager::install("BiocCheck")
getAPIcalls <- function(packageDir) {
annv <- BiocCheck:::parseFiles(packageDir)
annv <- annv[endsWith(dirname(names(annv)), "R")]
funnames <- c("Terra", "Rawls", "Leonardo", "Leo", "Dockstore")
reslist <- replicate(length(funnames), annv, simplify = FALSE)
names(reslist) <- funnames
@LiNk-NY
LiNk-NY / ggplot_gantt_releases.Rmd
Last active April 13, 2024 01:16
Create a Gantt Chart of Bioconductor Releases
---
title: "Bioconductor Release Schedule"
date: "2024-04-11"
html_output:
BiocStyle::html_output
---
## Dependencies
```{r}
@LiNk-NY
LiNk-NY / cyclo_comp.R
Created September 11, 2023 14:17
Example Reduction of Cyclomatic Complexity
hasValueSection <- function(manpage) {
rd <- tools::parse_Rd(manpage)
type <- BiocCheck:::docType(rd)
if (identical(type, "data"))
return(TRUE)
tags <- tools:::RdTags(rd)
if ("\\usage" %in% tags && (!"\\value" %in% tags))
return(FALSE)
value <- NULL
if ("\\value" %in% tags)
library(shiny)
library(purrr)
library(DT)
data("mtcars")
miniapp <- function(...) {
ids <- paste0("Tab2_Column", 1:5, "_Variable")
vchoices <- names(mtcars)
@LiNk-NY
LiNk-NY / trtools_review.Rmd
Last active February 15, 2023 16:55
trtools review
---
title: "Review of trtools"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
Test code to connect to clinical mart is showing an error:
@LiNk-NY
LiNk-NY / readproto.R
Last active December 21, 2022 16:57
Attempt to read in proto files with phenopackets schema
# gists/12f99b49d6c009f80ff49a8823ad47ea/readproto.R
library(RProtoBuf)
setwd("~/gh")
## git clone git@github.com:phenopackets/phenopacket-schema.git
## git submodule update --init --recursive
setwd("~/gh/phenopacket-schema/src/main/proto")
@LiNk-NY
LiNk-NY / getLastReleaseBuildDates.R
Created September 16, 2022 21:05
MRAN / RSPM repository resolution
library(rvest)
library(xml2)
library(lubridate)
library(yaml)
buildrep <- xml2::read_html("https://bioconductor.org/checkResults/")
html_text(html_nodes(buildrep, "li"))
nodes <- html_nodes(buildrep, "div")[-1:-2]
bioc_names <- html_text(html_nodes(nodes, "h3"))
library(BiocPkgTools)
library(dplyr)
dev <- biocBuildReport(version = BiocManager::version(), stage.timings = TRUE)
dev[["elapsed"]] <- as.numeric(
vapply(strsplit(dev[["EllapsedTime"]], " "), `[`, character(1L), 1L)
)
dev |> group_by(stage, node) |> summarize(n = n())
metrics_file <- "pbmc_granulocyte_sorted_3k_per_barcode_metrics.csv"
bm <- read.csv(metrics_file)
dim(bm)
## all unique barcodes
identical(length(unique(bm$atac_barcode)), length(bm$atac_barcode))
abcs <- bm[, "atac_barcode", drop = FALSE]
# with col.names = TRUE
@LiNk-NY
LiNk-NY / preprocess_forge_ASM19595v2.R
Created September 8, 2021 21:01
script for downloading and forging BSgenome for Mycobacterium tuberculosis
# setwd("~/ASM19595v2")
# dir.create(testdir <- normalizePath("~/ASM19595v2/"))
# setwd(testdir)
testfile <- normalizePath("./genome_assemblies_genome_fasta.tar")
wd <- dirname(testfile)
download.file("https://www.ncbi.nlm.nih.gov/projects/r_gencoll/ftp_service/nph-gc-ftp-service.cgi/?HistoryId=MCID_61391356369bba150d3809be&QueryKey=1&ReleaseType=RefSeq&FileType=GENOME_FASTA&Flat=true", testfile)
untar(testfile)
fastazip <- list.files(wd, recursive = TRUE, pattern = "fna.gz$")
library(BSgenome)
fasta.seqlengths(fastazip)