Skip to content

Instantly share code, notes, and snippets.

View magic-lantern's full-sized avatar

Seth Russell magic-lantern

  • University of Colorado Anschutz Medical Campus
  • North Carolina
View GitHub Profile
name: hvplot_example
channels:
- conda-forge
- defaults
dependencies:
- python=3.10
- hvplot
- intake
- intake-parquet
- intake-xarray
@magic-lantern
magic-lantern / jupyterhub_setup.md
Last active November 22, 2023 14:07
How to setup JupyterHub
@magic-lantern
magic-lantern / package_hold.md
Created May 18, 2022 20:43
How to hold packages from updating on Ubuntu 20.04

How to hold back or keep specific R version on Ubuntu

See https://askubuntu.com/questions/18654/how-to-prevent-updating-of-a-specific-package for additional details on package holding.

You have all system R packages as you want them:

If so, run the following:

apt-mark hold r-base r-base-core r-base-dev r-base-html r-cran-boot r-cran-class r-cran-cluster r-cran-codetools r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mass r-cran-matrix r-cran-mgcv r-cran-nlme r-cran-nnet r-cran-rpart r-cran-spatial r-cran-survival r-doc-html r-doc-info r-recommended
@magic-lantern
magic-lantern / base.R
Last active October 5, 2021 22:59
bigrquery_example.R
library(bigrquery)
library(magrittr)
library(dplyr)
library(tidyr)
project <- "gbqproject"
dataset_writeable <- "gbqdataset"
dataset_readonly <- "gbqdataset_source"
# test query to prompt for GBQ Credentials
# RStudio can't just run the whole file at once
@magic-lantern
magic-lantern / jupytext_readme.md
Created July 28, 2021 18:02
Jupytext configuration

Jupytext setup (for *nix and Windows)

Installation

Run this command to install the jupytext extension:

conda install jupytext -c conda-forge

Start/restart jupyter. In the environment used to launch jupyter notebook you should now see the File > Jupytext menu. In jupyter lab, Jupytext adds a set of commands to the command palette (View / Activate Command Palette, or Ctrl+Shift+C):

@magic-lantern
magic-lantern / !n3c_ml_intro.md
Last active May 21, 2021 01:13
N3C Machine Learning Introduction

N3C machine learning introduction

This machine learning example was developed for the paper "The National COVID Cohort Collaborative: Clinical Characterization and Early Severity Prediction" currently available as a preprint.

Although the code is available in the N3C Unite Palantir platform, for faster code sharing, I have made the following publically accessible exports of the workbooks:

  • Build ML Dataset - Pulls in many variables curated as part of the Cohort paper and does additional curation.
  • scikit-ML - Separation of dataset in to input and outcomes and seasonal versions
  • xgboost-ML - Grid search over XGBoost hyperparameters
  • Unsupervised ML - UMAP and PCA analysis of data
@magic-lantern
magic-lantern / nc_towns_and_counties.csv
Created April 21, 2021 01:54
North Carolina towns large enough for zip code and county
Aberdeen Moore
Advance Davie
Ahoskie Hertford
Alamance Alamance
Albemarle Stanly
Albertson Duplin
Alexander Buncombe
Alexis Gaston
Alliance Pamlico
Almond Swain
@magic-lantern
magic-lantern / rows_within_groups_sql.md
Last active September 18, 2020 03:52
How to get specific rows within a group Google BigQuery

How to get specific rows within a group in generic SQL (SQLite)?

Example scenario: Need to get all encounter rows and summary information about their labs such as min/max, and the value most immediately before and after an event of interest.

The following code will setup an example scenario. Some people have no labs, others only have labs before or only after the event of interest.

SQL Fiddle available at http://sqlfiddle.com/#!5/f80104/1/0

CREATE OR REPLACE TABLE encounter
@magic-lantern
magic-lantern / rows_within_groups_gbq.md
Last active September 18, 2020 03:49
How to get specific rows within a group Google BigQuery

How to get specific rows within a group in Google BigQuery?

Example scenario: Need to get all encounter rows and summary information about their labs such as min/max, and the value most immediately before and after an event of interest.

The following code will setup an example scenario. Some people have no labs, others only have labs before or only after the event of interest.

CREATE OR REPLACE TABLE curation.test_encounter
(
  person_id INT64 NOT NULL,
@magic-lantern
magic-lantern / Dockerfile
Created June 9, 2020 22:56
Dockerfile for R testing
# Test of docker build process
#
# ctd - Crash Test Dummy. "You can learn a lot from a dummy"
#
# Sample commnds
# date; docker build --tag ctd:1.0 .; date
# docker history ctd:1.0
# docker run -i -t ctd:1.0 /bin/bash
# this whole thing should take 30 - 35 minutes on first run
FROM rocker/r-ver:3.6.3