Skip to content

Instantly share code, notes, and snippets.

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

B. Ogan Mancarcı oganm

🤦‍♂️
View GitHub Profile
@oganm
oganm / shinyJsLogicalConclusion.R
Created January 8, 2018 08:40
ShinyJSLogicalConclusion
extendShinyjsEvenFurther = function(){
jscode <- '
Shiny.addCustomMessageHandler("mymessage", function(message) {
eval(message);
});
'
tags$head(tags$script(HTML(jscode)))
}
jsExecute = function(jscode,session){
@oganm
oganm / app.R
Created January 30, 2018 20:50
Update progress bar check to try on windows
library(shiny)
library(shinyWidgets)
moduleUI = function(id){
ns = NS(id)
tagList(actionButton(inputId = ns('update'),label = 'update'),
progressBar(id = "progressBar", value = 50),
checkboxInput(inputId = ns('checkbox'),label = 'shinyCheckbox',value = FALSE))
}
@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')
@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 / addSRD.R
Last active February 22, 2018 02:16
Editing grimoire
library(stringr)
library(magrittr)
library(pdftools)
library(Hmisc)
capitalizeAll = function(x){
words = strsplit(x, ' ') %>% {.[[1]]}
capital = sapply(words, function(x){
if(x %in% c('for','of','and','to','into','with','the','from','via')){
return(x)
@oganm
oganm / jqfp.js
Last active April 15, 2018 15:03 — forked from srvanderplas/jqfp.js
Shiny user fingerprint (md5 hash of browser characteristics) and ip address demo. The .R files are in the working directory ("./"), the .js files must be placed in ./www/js/ to be accessible.
// Browser fingerprinting is a technique to "mark" anonymous users using JS
// (or other things). To build an "identity" of sorts the browser is queried
// for a list of its plugins, the screen size and several other things, then
// hashes them. The idea is that these bits of information produce an unique
// "fingerprint" of sorts; the more elaborate the list of data points is, the
// more unique this fingerprint becomes. And you wouldn't even need to set a
// cookie to recognize this user when she visits again.
//
// For more information on this topic consult
// [Ars Technica](http://arstechnica.com/tech-policy/news/2010/05/how-your-web-browser-rats-you-out-online.ars)
@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 / 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 / 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 / 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],