Skip to content

Instantly share code, notes, and snippets.

View vjcitn's full-sized avatar

Vince Carey vjcitn

View GitHub Profile
@vjcitn
vjcitn / SCPDockerFIle
Created June 15, 2023 21:14
A dockerfile for working with R (quickly via r2u) and SCP from Hao Zhang
FROM ubuntu:jammy
LABEL org.label-schema.license="GPL-2.0" \
org.label-schema.vcs-url="https://github.com/rocker-org/" \
org.label-schema.vendor="Rocker Project" \
maintainer="Dirk Eddelbuettel <[email protected]>"
## Set a default user. Available via runtime flag `--user docker`
## Add user to 'staff' group, granting them write privileges to /usr/local/lib/R/site.library
## User should also have & own a home directory (for rstudio or linked volumes to work properly).
@vjcitn
vjcitn / colorapp2.R
Created August 8, 2023 18:39
simple color model exploration with shiny
library(shiny)
colorapp2 = function ()
{
colordot = function (r, g, b) {
plot(0, 0, col = grDevices::rgb(r, g, b), pch = 19, cex = 15)
}
ui = fluidPage(
sidebarLayout(
sidebarPanel(
@vjcitn
vjcitn / happ.R
Created August 10, 2023 19:47
defines function happ() to manipulate image of activated mast cell
library(shiny)
library(imager)
mpath = "https://mghp.osn.xsede.org/bir190004-bucket01/BiocGeneralData/mast.jpg"
happ = function () {
ui = fluidPage(
sidebarLayout(
sidebarPanel(
helpText("slider for cannyEdges alpha"),
sliderInput("alpha", "alpha", min = 0, max = 1, step = 0.05,
@vjcitn
vjcitn / gist:cb316b89d08be63ebc9e3c9194e17b36
Created September 6, 2023 13:55
import semantic SQL content to ontology_index
#' produce an ontology_index instance from semantic sql sqlite connection
#' @param con DBI::dbConnect value for sqlite table
#' @return result of ontologyIndex::ontology_index evaluated for the labels and
#' parent-child relations in tables statements and edge of the semantic sql resource
#' @export
semsql_to_oi = function(con) {
# sqlite> select * from statements where predicate = 'rdfs:label' limit 40;
alltabs = DBI::dbListTables(con)
stopifnot(all(c("edge", "statements") %in% alltabs))
labdf = dplyr::tbl(con, "statements") |> dplyr::filter(predicate == "rdfs:label") |>
@vjcitn
vjcitn / check_discrepant_pkgs.R
Created October 1, 2023 00:08
code in this gist attempts to prepare R to identify causes of CHECK_SUGGESTS_ONLY errors
stopifnot(Sys.getenv("_R_CHECK_SUGGESTS_ONLY_") == "true")
# these error in check on nebbiolo2 but not lconway
suggposs = c("AffyRNADegradation", "alabaster.spatial", "ANF", "animalcules",
"BDMMAcorrect", "bnbc", "CancerSubtypes", "ccrepe", "CDI", "cellscape",
"ClassifyR", "CNVgears", "CoGAPS", "compartmap", "CoRegNet",
"crisprseekplus", "DEWSeq", "DEXSeq", "DMCFB", "dpeak", "DSS",
"EasyCellType", "eegc", "EGSEA", "EpiCompare", "exomePeak2",
"farms", "FCBF", "flowMap", "FoldGO", "FScanR", "GCSscore", "GenomicFeatures",
"GEOmetadb", "GEOquery", "gscreend", "HelloRanges", "ILoReg",
@vjcitn
vjcitn / igandemo.R
Created October 6, 2023 10:14
neo4r and biocypher
# assumes https://github.com/biocypher/igan.git README instructions
# followed, docker compose up -d succeeded and localhost:7474 gives
# a neo4j browser interface (at localhost:7687/browser on my machine)
#
# BiocManager::install("neo4j-rstats/neo4r")
# want 0.1.3
library(neo4r)
library(magrittr)
con <- neo4j_api$new(
url = "http://localhost:7474", user="", password="")
@vjcitn
vjcitn / newlib.R
Created November 11, 2023 11:32
a redefinition of library() to be quieter
# a replacement for library() that does not print tons of messages
# as each package is loaded. place in .Rprofile
libstats = function(inisess, newsess) {
inibase = inisess$basePkgs # unchanging?
inioth = names(inisess$otherPkgs)
newbase = newsess$basePkgs
newoth = names(newsess$otherPkgs)
iniatt = length(unique(c(inibase,inioth)))
newatt = length(unique(c(newbase,newoth)))
@vjcitn
vjcitn / gist:da11ea5228124fd06c5e59239a54cb9d
Created December 9, 2023 14:52
using shiny with readVcf, predictCoding, ...
library(shiny) # works with the chr22.vcf.gz in the VariantAnnotation extdata
library(dplyr)
library(DT)
library(VariantAnnotation)
library(BSgenome.Hsapiens.UCSC.hg19)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
ui <- fluidPage(
titlePanel("VCF XPLORR"),
numericInput("numvar", "num2chk", value = 50, min = 50, max = 500, step = 10),
#
# https://priyanshwarke2015-ndcs.medium.com/image-classification-with-cnn-model-in-cifar100-dataset-8d4122b75bad
# with user-level miniconda3 installed, use
# miniconda3/bin/pip install matplotlib
# miniconda3/bin/pip install torchvision
import os
import torch
import torchvision