Skip to content

Instantly share code, notes, and snippets.

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

B. Ogan Mancarcı oganm

🤦‍♂️
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / parser.R
Created January 12, 2019 01:05
miniparser
library(dplyr)
generatePatterns = function(patterns, # final outputs here
helperPatterns = NULL, # intermediate patterns that won't be returned here
.open= '{', .close = '}'){
for (i in seq_along(helperPatterns)){
helperPatterns[[i]] = with(helperPatterns[1:i],
{glue::glue(helperPatterns[[i]],
@oganm
oganm / notes.lua
Created February 9, 2019 22:56
luanotes
for i in pairs(table) do print(i) end -- list things in table
@oganm
oganm / terrainStuff.R
Created March 26, 2019 21:44
terrain stuff
library(rayshader)
library(ambient)
k = 8
m = noise_perlin(dim = c(2^k,2^k),octaves = 9)
mToMap(m)
m = noise_simplex(c(2^k,2^k),fractal = 'fbm',octaves = 4,lacunarity = 2,gain = .5,frequency = .01)
@oganm
oganm / pkgRank.R
Created May 8, 2019 21:40
cranlogs package rank
library(cranlogs)
library(dplyr)
allPackages = available.packages() %>% rownames
groups = cut(seq_along(allPackages), breaks = seq(0,length(allPackages),20)) %>% {.=as.character(.);.[is.na(.)]='last';factor(.,levels = unique(.))}
package_groups = split(allPackages,groups)
package_groups %>% lapply(function(x){