Skip to content

Instantly share code, notes, and snippets.

View forstater's full-sized avatar

Jacob Forstater forstater

View GitHub Profile
@forstater
forstater / server.r
Created August 31, 2016 14:11 — forked from wch/server.r
Shiny example: dynamic input fields
data_sets <- c("mtcars", "morley", "rock")
shinyServer(function(input, output) {
# Drop-down selection box for which data set
output$choose_dataset <- renderUI({
selectInput("dataset", "Data set", as.list(data_sets))
})
# Check boxes
@forstater
forstater / jacobs_nanopore_functions.py
Last active August 9, 2016 23:30
Useful Functions for Analyzing Nanopore Data with MOSAIC
'''
:Author: Jacob Forstater <[email protected]> or <[email protected]>
:Description: Various functions/workflow that help to process nanopore data
Log:
JF 20160809 initial public commit
'''
@forstater
forstater / multiStateFilter.py
Created June 28, 2016 20:23
Function to query and filter multistate events.
'''
Author: Jacob Forstater
Description: Workflow to clean up multistate events
- Filters out NStates <2
- Filters out any event with StateResTime < minValue
- Supplys this back as a 2D flattened Array
Log:
JF 20160602 initial version
@forstater
forstater / calcBinSize.py
Created May 25, 2016 19:35
Script to calculate optimal bin sizing using minimization of integrated square area
"""
Script to calculate optimal bin size (bandwidth).
:Created: 5/25/2016
:Author: Jacob Forstater <jacob.forstater@nist.gov>
:Reference: Shimazaki and Shinomoto. Histogram Binwidth Optimization Method. Neural Comput. v19 pp1503-1527 (2007)
:Original Source: Modified from http://toyoizumilab.brain.riken.jp/hideaki/res/histogram.html
:ChangeLog:
.. line-block::
@forstater
forstater / useful_pandas_snippets.py
Last active December 2, 2016 16:18 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@forstater
forstater / gist:9fb3f3fa8cc1828ce95a
Created February 11, 2016 16:50 — forked from why-not/gist:4582705
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""quick way to create a data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
df['A'] """ will bring out a col """ df.ix[0] """will bring out a row, #0 in this case"""
"""to get an array from a data frame or a series use values, note it is not a function here, so no parans ()"""
point = df_allpoints[df_allpoints['names'] == given_point] # extract one point row.
point = point['desc'].values[0] # get its descriptor in array form.
@forstater
forstater / binaryConvert.py
Last active August 29, 2015 14:27 — forked from abalijepalli/binaryConvert.py
A Python gist to convert any data type supported by MOSAIC (https://github.com/usnistgov/mosaic) to a simple binary format.
"""
Extend the MOSAIC ConvertToCSV class to export arbitrary binary files.
:Created: 02/25/2015
:Author: Arvind Balijepalli <[email protected]>
:ChangeLog:
.. line-block::
02/25/15 AB Initial version
"""
import mosaic.ConvertToCSV as conv