Skip to content

Instantly share code, notes, and snippets.

View oganm's full-sized avatar
🤦‍♂️

B. Ogan Mancarcı oganm

🤦‍♂️
View GitHub Profile
@oganm
oganm / se.R
Last active December 6, 2019 00:32
dplyr standard evaluation recipes
library(dplyr)
diamonds = ggplot2::diamonds
filterBy = 'color'
diamonds %>% filter(!!rlang::sym(filterBy) == 'E')
diamonds %>% group_by(!!rlang::sym(filterBy))
diamonds %>% mutate(!!rlang::sym('new_col'):='yes')
@oganm
oganm / mri.R
Last active October 23, 2018 00:41
play with mri data
library(OpenImageR)
library(oro.dicom)
library(dplyr)
library(magrittr)
library(magick)
dicompath = '/home/omancarci/Dropbox/MRI'
imageFiles = list.files(file.path(dicompath,'DICOM'),recursive = TRUE,full.names = TRUE)
@oganm
oganm / get_random_names.R
Last active October 22, 2018 21:12
random docker style names
library(dplyr)
# available names stolen from https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go----------------------
left = c("admiring",
"adoring",
"affectionate",
"agitated",
"amazing",
"angry",
"awesome",
@oganm
oganm / getGithubFile.R
Last active October 16, 2018 19:45
download single files from private or public github repositories
getGithubFile = function(githubPath,branch = 'master', downloadPath = NULL,token = NULL){
if(is.null(downloadPath)){
downloadPath = tempfile()
}
path = strsplit(githubPath,'/')[[1]]
file = paste(path[3:length(path)], collapse = '/')
contents = gh::gh('GET /repos/:username/:reponame/contents/:dir?ref=:branch',
username = path[1],
reponame = path[2],
@oganm
oganm / punchcard.R
Last active October 2, 2021 13:29
a punchcard of git commits for a given repo
# this is to get data from a single git repository
library(dplyr)
library(anytime)
library(patchwork)
library(ggplot2)
commits = git2r::commits()
commitTime= commits %>% sapply(function(x){x$author$when$time}) %>% anytime
@oganm
oganm / simpleEnrichment.R
Last active September 25, 2018 00:06
gene set enrichment for marker genes
library(magrittr)
library(dplyr)
library(homologene)
library(gemmaAPI) # github.com/pavlidisLab/gemmaAAPI.R
library(markerGeneProfile) # github.com/pavlidisLab/markerGeneProfile
data("mouseMarkerGenesCombined")
# get mouse homologues of the hitlist
hitlist = readxl::read_xlsx('gene of interest.xlsx',col_names = FALSE) %>%
unlist %>% human2mouse %$% mouseGene
@oganm
oganm / compileChars.R
Created July 17, 2018 01:52
compile chars backup
library(import5eChar)
library(purrr)
library(ogbox)
library(dplyr)
library(ggplot2)
library(stringr)
library(igraph)
library(glue)
library(cowplot)
charFiles = c(list.files('/srv/shiny-server/printSheetApp/chars/',full.names = TRUE),
@oganm
oganm / lilahFiles.R
Created May 15, 2018 05:03
lilah's gene list for publication
regions = c('Cortex','Hippocampus','Striatum','Cerebellum','Thalamus')
regions %>% lapply(function(x){
cellTypes = names(mouseMarkerGenesCombined[[x]])
cellTypes %>% lapply(function(y){
data.frame(symbol = mouseMarkerGenesCombined[[x]][[y]], NCBIid = mouseMarkerGenesCombinedNCBI[[x]][[y]])
})
})
@oganm
oganm / geneListCellCode.R
Created February 20, 2018 00:42
CellCODE with gene lists
library(CellCODE)
library(dplyr)
library(purrr)
library(magrittr)
library(markerGeneProfile)
data('mouseMarkerGenesCombined')
# this function will turn gene lists into CellCODE inputs
cellCodeInput = function(genes){
geneCount = genes %>% map(length)
@oganm
oganm / ontologyPlay.R
Created February 14, 2018 01:31
playing with ontologies
# ontologyPlot package requires bioconductor package Rgraphvis
# source("https://bioconductor.org/biocLite.R")
# biocLite("Rgraphvis")
# install.packages('ontologyIndex')
# install.packages('ontologyPlot')
library(ontologyIndex)
library(ontologyPlot)
download.file(url = 'http://purl.obolibrary.org/obo/uberon.obo',destfile = 'uberon.obo')