Skip to content

Instantly share code, notes, and snippets.

View callahantiff's full-sized avatar
🦈
beep bop booping

Tiffany J. Callahan callahantiff

🦈
beep bop booping
View GitHub Profile
@callahantiff
callahantiff / swirl_training.nb.html
Last active July 9, 2018 17:29
swirl_training: this code is used to install and load the R swirl library and all swirl lesson plans. This document was created for the 2018 CHCO R Training
---
title: "CHCO R Training"
subtitle: "Hands-on Experience using swirl"
author: "Tiffany J. Callahan"
output: html_notebook
---
# Purpose
This [R Markdown Notebook](http://rmarkdown.rstudio.com) is intended to be used for all [swirl](https://swirlstats.com/) lessons as part of the CHCO R Training. It contains all the code needed to download and install all R swirl lessons. It also includes. Participants in the training are encouraged to create a new code chunk for each lesson. Participants should this to document their progress and to note areas for improvement.
/* DEMOGRAPHICS */
SELECT DISTINCT pat.pat_id, pat.pat_mrn_id AS mrn, pat.pat_last_name AS last_name, pat.pat_first_name AS first_name,
substr(pat.pat_middle_name,1,1) AS mid_initial, pat2.maiden_name AS maiden_name, pat.birth_date AS dob, c.name AS county,
s.name AS state, pat.zip AS zip, enc.contact_date AS encounter_date, floor(months_between(enc.contact_date, pat.birth_date)/12) AS age,
(CASE WHEN sex.abbr='oth' THEN 'o' ELSE sex.abbr END) AS sex,
(SELECT listagg(race.name, ',') WITHIN GROUP (ORDER BY pr.line)
FROM clarity.patient_race pr, clarity.zc_patient_race race
@callahantiff
callahantiff / install_load_multiple.R
Created July 6, 2018 17:27
Install and load multiple R packages needed for CHCO R Training
# install list of packages
install.packages(c("dplyr", "dbplyr", "swirl", "odbc", "RODBC", "knitr", "DBI", "packrat", "rstudioapi", "rmarkdown", "codetools", "devtools", "ggplot2"))
# load installed packages
my_packages <- c("dplyr", "dbplyr", "swirl", "odbc", "RODBC", "knitr", "DBI", "packrat", "rstudioapi", "rmarkdown", "codetools", "devtools", "ggplot2")
lapply(my_packages, library, character.only = TRUE)
@callahantiff
callahantiff / import_export.nb.html
Last active July 10, 2018 14:33
R Notebook for CHCO R Training: Importing and Exporting Data
---
title: "CHCO R Training"
subtitle: "Hands-on Experience Importing and Exporting Data"
author: "Tiffany J. Callahan"
output: html_notebook
---
# Purpose
This [R Markdown Notebook](http://rmarkdown.rstudio.com) is intended to be used for practicing importing and exporting different kinds of data. This Notebook contains code for importing the following types of data:
* [Flat Files](#txt)
@callahantiff
callahantiff / rare_disease_geo_analysis.Rmd
Last active July 28, 2018 07:03
Rare Disease GEO Analysis - R Notebook
---
title: 'MetaOmic: Transcriptomic Data Analysis'
author: 'Tiffany J. Callahan'
date: 'July 27, 2018'
output:
html_notebook: default
html_document: default
---
---
@callahantiff
callahantiff / Clinical_Concept_Annotator
Last active July 31, 2018 15:27
Script annotates clinical concepts to ontology terms using the NCBO API
##########################################################################################
# Concept_Annotator.py
# Purpose: script annotates clinical concepts to ontology terms using the NCBO API
# version 1.0.0
##########################################################################################
import urllib2
import json
@callahantiff
callahantiff / OMOP2OBO_ConceptPrevalence_ErrorAnalysis.sql
Last active October 30, 2020 02:20
OMOP2OBO - OMOP Concept Queries: used to pull the OMOP concepts for input into the OBO mapping pipeline
SELECT
DISTINCT r.relationship_id,
c1.concept_id AS SOURCE_CONCEPT_ID,
c1.concept_name AS SOURCE_CONCEPT_LABEL,
c2.concept_id AS TARGET_CONCEPT_ID,
c2.concept_name AS TARGET_CONCEPT_LABEL,
FROM
sandbox-omop.oct_2020.concept_relationship r
JOIN sandbox-omop.oct_2020.concept c1 ON c1.concept_id = r.concept_id_1
JOIN sandbox-omop.oct_2020.concept c2 ON c2.concept_id = r.concept_id_2
@callahantiff
callahantiff / source_code_query.sql
Last active April 9, 2019 04:35
PheKnowVec_Source_Code_Query
-- Query Template: find exact matches between source vocabulary code strings and an OMOP standard terminology concept code
SELECT DISTINCT
CONCAT('"', c.concept_code, '"') AS source_code,
c.concept_name AS source_name,
c.domain_id AS source_domain,
c.vocabulary_id AS source_vocabulary,
CONCAT('"', c1.concept_code, '"') AS standard_code,
c1.concept_name AS standard_name,
c1.domain_id AS standard_domain,
c1.vocabulary_id AS standard_vocabulary
@callahantiff
callahantiff / source_string_query.sql
Last active April 9, 2019 04:23
PheKnowVec_Source_String_Query
-- Query Template: find OMOP concept codes with a label that partially matches a source string
SELECT
source_string,
CONCAT('"', source_code, '"') AS source_code,
source_name,
source_domain,
source_vocabulary
FROM
(SELECT DISTINCT
@callahantiff
callahantiff / standard_code_desc_query.sql
Last active April 8, 2019 03:26
PheKnowVec_Standard_Code_Desc_Query
-- Query Template: find descendants of OMOP standard terminology concepts
SELECT DISTINCT
CONCAT('"', c.concept_code, '"') AS source_code,
c.concept_name AS standard_name,
c.domain_id AS standard_domain,
c.vocabulary_id AS standard_vocabulary,
CONCAT('"', dc.concept_code, '"') AS desc_standard_code,
dc.concept_name AS desc_standard_name,
dc.domain_id AS desc_standard_domain,
dc.vocabulary_id AS desc_standard_vocabulary