Skip to content

Instantly share code, notes, and snippets.

View aaiezza's full-sized avatar

Alessandro Aiezza aaiezza

View GitHub Profile
@aaiezza
aaiezza / plotNorm.R
Created June 27, 2017 14:15
ggplot2 plotting function for a Normal Distribution with lightly shaded and labeled standard deviations from the mean. User may also give lower and upper bounds, which adds shading under the curve between those points and a label with the area under the curve. (Made to accommodate for Mathematical Statistics with Applications 7th Ed. - WMS 2008)
##
# Standard function for printing Normal Distribution in ggplot2
# # # #
plotNormCurve <- function( mean = 0, sd = 1, variance = sd ^ 2,
lowerBound = NULL, upperBound = NULL,
sdRange = 3.5,
from = mean - (sdRange * sd),
to = mean + (sdRange * sd),
plotTitle = 'Normal Curve', xlab = 'x', ylab = 'density'
)
@aaiezza
aaiezza / RNA-Seq_plotUtils.R
Created June 29, 2017 17:06
Miscellaneous functions used for plotting gene data.
#!/usr/bin/Rscript
suppressMessages( library( calibrate ) )
suppressMessages( library( ggplot2 ) )
suppressMessages( library( ggrepel ) )
suppressMessages( library( ggdendro ) )
suppressMessages( library( dendextend ) )
suppressMessages( require( htmlwidgets ) )
suppressMessages( require( gridExtra ) )
suppressMessages( require( plotly ) )
@aaiezza
aaiezza / RNA-Seq_templateAnalysis.R
Created June 29, 2017 17:14
Template Analysis of RNA-Seq Data.
#!/usr/bin/Rscript
## Properties
FRM_GENE_FILE <- 'frm_gene_exp.diff.txt'
FAV_COLS <- c( 'gene', 'sample_1', 'sample_2', 'value_1', 'value_2', 'log2(fold_change)', 'q_value' )
GENE_ID_FILTER <- '^((Mir([\\d]|let)+.*)|---|LOC\\d+|(.*Rik.*))$'
HEATMAPS_DIR <- 'heatmaps'
VOLCANO_WIDGET_DIR <- 'interactiveVolcanoPlots'
## Package Dependencies
@aaiezza
aaiezza / randomTools.R
Created June 29, 2017 17:15
Random R functions. Most notably helpful is the Logger function.
#!/usr/bin/Rscript
options( width = 120, warn = -1 )
# # # #
# # Just some random R functions that are helpful # #
# Override defaults of functions
# gsub <- function( pattern, replacement, x, ignore.case = FALSE, perl = TRUE, fixed = FALSE, useBytes = FALSE )
# {
# return( gsub(pattern, replacement, x, ignore.case = ignore.case, perl = perl, fixed = fixed, useBytes = useBytes) );
@aaiezza
aaiezza / RNA-Seq_enrichmentAnalysis.R
Last active February 24, 2021 21:53
Functions for performing and analyzing RNA-Seq Enrichment Analysis from multiple tools. Notably DAVID, Homer, and GeneTrail2.
#!/usr/bin/Rscript
suppressMessages( source( '/cvri/Rutils/randomTools.R' ) )
##
# Analyze the results of HOMER after it runs
#
analyzeHomerEnrichment <- function(
dir = 'goi', toFiles = FALSE,
n = 5 )
@aaiezza
aaiezza / RNA-Seq_xlsxWriter.R
Created June 29, 2017 17:18
Wrapper functions for creating RNA-Seq differential expression analysis reports in Excel spreadsheets.
#!/usr/bin/Rscript
suppressMessages( require( stringr ) )
options( java.parameters = "-Xmx32g" )
suppressMessages( require( rJava ) )
.joptions( java.parameters = "-Xmx32g" )
.jinit()
@aaiezza
aaiezza / nucleotidesSlidingWindow.R
Created July 14, 2017 18:13
Nucleotides Sliding Window
require( zoo )
require( iterpc )
# Could be retreived from anywhere of course…
nucleotideSequence <- sample( c('A','T','C','G'), 1000, replace=TRUE, prob=c(.1,.1,.4,.4) )
windowWidth <- 3
kmers <- rollapply( nucleotideSequence, width = windowWidth, by = 1, paste, collapse='' )
possibleKmers <- apply( getall( iterpc(4, 3, c('A','T','C','G'), replace = TRUE) ), 1, paste, collapse = '' )
@aaiezza
aaiezza / debtSnowball.R
Last active October 25, 2020 15:54
Function for determining how long an optimal Debt Snowball will take to pay off. Takes only current principals and interest rates. Does not take minimum payments or account for compounding.
loanData <- data.frame(
description = c(
'1-03 Direct Loan - Unsubsidized',
'1-02 Direct Loan - Subsidized',
'Direct Unsubsidized Stafford',
'Direct Unsubsidized Stafford',
'1-01 Direct Loan - Unsubsidized',
'Direct Unsubsidized Stafford',
'Direct Subsidized Stafford',
'Direct Unsubsidized Stafford',
@aaiezza
aaiezza / findActionsWithType.jq
Last active June 19, 2018 18:19
Retrieve embedded actions with a "type" key
"type" as $filter |
._embedded | to_entries
| map({(if (.value | has($filter)) then .key else empty end): .value|keys})
| add
## Sample command:
# curl --silent https://api.financialwellness.com/task/tasklist/index | jq -Cf findActionsWithType.jq
@aaiezza
aaiezza / currentversion.sh
Last active April 20, 2020 13:06
Maven Project | Bump Major, Minor, or Patch Sematic Version
currentversion() {
# If xpath is on your machine (macos will I believe),
# and the project's version is in the path `project.version`,
# then it is nice to use this because it is faster.
# xpath ./pom.xml 'project/version/text()' 2>/dev/null
# Otherwise:
mvn help:evaluate -Dexpression=project.version -q -DforceStdout
}