Skip to content

Instantly share code, notes, and snippets.

View adamsardar's full-sized avatar

Adam Sardar adamsardar

View GitHub Profile
@adamsardar
adamsardar / CoW_assign.py
Last active March 8, 2024 16:40
Column creation and copies
#%%
import copy
import timeit
import pandas as pd
import polars as pl
#%%
# Use pandas, but no need to make a defensive copy
@adamsardar
adamsardar / installRpackagesViaApt.R
Created May 11, 2021 09:38
Dependencies can be installed with aptitude for much faster build times. However, you are at the mercy of whatever R version is in the repos
pkgDeps <- remotes::local_package_deps('.', dependencies=TRUE);
pkgDeps <- setdiff(pkgDeps, .packages(all.available = TRUE));
debCRANpkgs <- tolower(paste('r-cran-', pkgDeps, sep = ''));
debBIOCpkgs <- tolower(paste('r-bioc-', pkgDeps, sep = ''));
debPkgsAvailable <- RcppAPT::hasPackages(c(debCRANpkgs,debBIOCpkgs));
binariesToInstall <- names(debPkgsAvailable)[which(debPkgsAvailable)];
#Set command prefix to be like screen
set -g prefix C-a
unbind C-b
bind C-a send-prefix
#Set up the status bar
set -g status-right '#[fg=green][#[fg=blue]%Y-%m-%d #[fg=yellow]%H:%M#[default]#[fg=green]]'
set -g status-bg black
set -g status-fg white
set -g status-left '#[fg=green]#(echo `whoami`)#[fg=white]@#[fg=magenta]#H'
@adamsardar
adamsardar / .Rprofile
Last active January 8, 2021 09:37
My standard Rprofile
#Including arch is useful for times that one might be running two versions of R on different architectures. e.g. on new M1 Macs
libDirectory <- paste(c("~/Rlibs/", R.Version()$minor, "/", R.Version()$arch, "/"),collapse="")
.libPaths(libDirectory)
#Taken from bioconductor. This removes the need for using biocLite to install packages, which would be at the top of my list of "Bad Things About R"
biocVersion <- "3.12"
biocMirror <- getOption("BioC_mirror", "https://bioconductor.org")
biocPaths <- c(BioCsoft = "bioc", BioCann = "data/annotation", BioCexp = "data/experiment")
@adamsardar
adamsardar / graphIO.R
Last active April 7, 2016 10:41
A igraph writer for graphml that names nodes with accession fields
pacman::p_load(igraph,stringr,data.table,utils,ensurer,magrittr)
#' Write an igraph object to file in graphML format
#'
#' A frustrating feature of igraph is the lack of ability to affect the nodeID field of an output graphML file.
#' I ended up becoming so frustrated that I just wrote my own.
#'
#' @param graph2Write An igraph object containing a uniquely labelled 'name' vertex attribute (which is used as nodeID)
#' @param filename The filename to write out the graphml file to
#' @return filename The filename of the graphML file
@adamsardar
adamsardar / mergeGraphs.R
Last active April 8, 2016 09:13
A utility function for stapling together igraph graphs
pacman::p_load(igraph,data.table,magrittr)
mergeGraphs <- function(...,desiredEdgeAttributes = c("from","to","edge_type"), omitNAnodes = TRUE){
graphList <- list(...)
tryCatch({