Skip to content

Instantly share code, notes, and snippets.

View cgpu's full-sized avatar
:octocat:

Christina Chatzipantsiou cgpu

:octocat:
View GitHub Profile
@cgpu
cgpu / imputeLCMD_vignette.Rmd
Last active September 9, 2018 08:08
Imputation with `imputeLCMD::impute.MinDet`. Used with a transposed dataframe so that the q-th quartile minimal value is drawn from feature's distribution of observed values and not from instance's (aka patient, subject, animal, individual etc))
---
title: 'Imputation of missing data:`impute.MinDet` function from the R package `imputeLCMD`, `missForest` for Random Forest imputation, `impute.knn` function for knn imputation'
author:
- name: "cristina "
affiliation:
email: ""
date: ""
toc: true
output:
rmarkdown::github_document:
@cgpu
cgpu / install_package.md
Last active January 14, 2019 00:14
When errors for not available for current version kick in

Do not check from source

options(install.packages.check.source = "no")
# Install packages from cran
install.packages("stringi", repos="http://cran.rstudio.com/", dependencies=TRUE)
@cgpu
cgpu / ifRequire_batch_check_install.R
Created September 13, 2018 08:26
From a list of R packages, check which aren't installed, do install them.
# Stack gem here: https://stackoverflow.com/questions/4090169/elegant-way-to-check-for-missing-packages-and-install-them
list.of.packages <- c("ggplot2", "Rcpp")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
@cgpu
cgpu / install_Rpckg_with_pacman_or_Librarian.md
Last active January 15, 2019 14:57
Elegant R package (down)loading with the `pacman` R package

title: "Sleek R meta-packages: Pakages that handle package (downloading)" author: "" date: "" output: html_document: toc: true # table of content true toc_depth: 3 # upto three depths of headings (specified by #, ## and ###) toc_float: true number_sections: true # if you want number sections at each table header

# Python-script header etiquette:
# https://stackoverflow.com/questions/1523427/what-is-the-common-header-format-of-python-files
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author : cristina
@cgpu
cgpu / RmdCodeHider.Rmd
Created October 15, 2018 10:57
Snippet to prevent code printing in html affter knitting.
---
title: "Preventing code from being printed on html output"
author: "cgpu"
date: ""
output: html_document
---
```{r global_options, include=FALSE}
knitr::opts_chunk$set(echo=FALSE, warning=FALSE, message=FALSE)
```
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: cristina
Script for parsing all JAD output .txt files of an input_directory
to collect ref and equivalent signatures based on user defined threshold for ROC AUC.
User defined arguments:
@cgpu
cgpu / JADBio_parser_args.py
Last active October 15, 2018 13:10
from JADBio_parser_args import JADBioparser
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: cristina
Script for parsing all JAD output .txt files of an input_directory
to collect ref and equivalent signatures based on user defined threshold for ROC AUC.
User defined arguments:
@cgpu
cgpu / featureSwapper.R
Created October 17, 2018 14:18
Script that takes as input: (i) a mapping dataframe with at least 2-columns with feature IDs (1 row = feature pair), (ii) a template dataframe with occurences of the features in column_1 of the mapping dataframe. The ouput is a dataframe of identical format with the template dataframe, but with swapped IDs, aka if occurence a = template_df$col_1…
# WHAT : Script for swapping feature IDs in a dataframe.
# Mapping dataframe required for swapping.
# A mapping dataframe should contain a minimal of
# two columns, one named 'current', the other `previous`,
# One row corresponds to one matching pair.
# Each row j of mapping df, one feature pair.
# Values are checked cell by cell (df[k,i]).,
# in df with values to be swapped.
@cgpu
cgpu / github_souRcery.md
Last active December 28, 2018 03:22
How to source .R scripts from github; works for (i) .R scripts stored in projects' repos or (ii) .R scripts saved as gists.

title: "How to source .R scripts from github; works for (i) .R scripts stored in projects' repos or (ii) .R scripts saved as gists." author: "cgpu" date: "" output: html_document: toc: true # table of content true toc_depth: 3 # upto three depths of headings (specified by #, ## and ###) toc_float: true number_sections: false # if you want number sections at each table header