Skip to content

Instantly share code, notes, and snippets.

View aurora-mareviv's full-sized avatar

aurora-mareviv

View GitHub Profile
@ofchurches
ofchurches / gist:da902a393ce8e529b33ca0a137cd5ff3
Last active April 28, 2020 00:40
tidy_tuesday_20200421
library(tidyverse)
library(tidytext)
library(wordcloud)
library(reshape2)
# Plot 1: Sentiment wordcloud.
gdpr_text <- readr::read_tsv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-04-21/gdpr_text.tsv')
#base on https://www.tidytextmining.com/sentiment.html
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
pmId
23552565
26655164
26077880
26164471
25135986
24978892
24467976
24180712
#########################################################
#### CAPTURE ABSTRACTS FROM PMIDs & MAKE A WORDCLOUD ####
#########################################################
# GNU-GPL license
# Author: Mareviv (https://talesofr.wordpress.com)
# Script to retrieve and mine abstracts from PubMed (http://www.ncbi.nlm.nih.gov/pubmed)
# Uses the function ReadPubMed from the package RefManageR. It reads the PubMed API similarly to the search engine in PubMed's page.
# This script creates two directories in your working directory: 'corpus1' for the abstracts file, and 'wordcloud' to store the plot.
% This is a Sweave template from TalesofR.wordpress.com.
% When a line is preceeded by a "%" sign, it will be ignored by the program.
% You can write what you want in this way. It usually serves for making invisible comments.
% If you want to make a comment inside the chunk of R code, the symbol to start the line must be "#", instead of "%"
% Let's start with the template:
\documentclass{article}
\begin{document}
% chunks of R code are initiated by "<>=", and ended by "@"
@aurora-mareviv
aurora-mareviv / mthacases.R
Last active August 29, 2015 14:24
Sample size and power calculation for mtDNA association studies. Based in Samuels et al., AJHG 2006, PMC1424681
################################
### 1. FORMULA SAMUELS CALC ####
####### NCMIN-HAPLOGROUPS ######
################################
# Under GPL license
# AUTHOR: A. Baluja
# Original formulae in Samuels et al., AJHG 2006, PMC1424681. Written in R by A. Baluja.
@aurora-mareviv
aurora-mareviv / server.R
Last active August 29, 2015 14:14
Chi-square power / sample estimations with R!
#under GNU General Public License
#server.R
library(shiny)
library(pwr)
shinyServer(function(input, output) {
## My pwr function:
f <- function(eff.size, n.observs, degfree, signif) {
@aurora-mareviv
aurora-mareviv / pmidata.2.R
Last active September 22, 2016 23:10
PMIDs database, semi-automatized
#########################################################
#### CAPTURE ARTICLE INFO, IMPACT FACTORS FROM PMIDs ####
#########################################################
# Script to retrieve and organise publications data from PubMed (http://www.ncbi.nlm.nih.gov/pubmed)
# Uses the function ReadPubMed from the package RefManageR. It reads the PubMed API similarly to the search engine in PubMed's page.
# First, automagically install needed libraries:
list.of.packages <- c("RCurl", "RefManageR", "devtools", "plyr", "XML", "data.table")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
@gavinsimpson
gavinsimpson / Deriv.R
Last active May 25, 2024 08:50
R functions to compute and plot the first derivative of a spline term in a GAM(M) fitted by `gam()` or `gamm()` in package mgcv
################################################
## Functions for derivatives of GAM(M) models ##
################################################
Deriv <- function(mod, n = 200, eps = 1e-7, newdata, term) {
if(inherits(mod, "gamm"))
mod <- mod$gam
m.terms <- attr(terms(mod), "term.labels")
if(missing(newdata)) {
newD <- sapply(model.frame(mod)[, m.terms, drop = FALSE],
function(x) seq(min(x), max(x), length = n))
@mrdwab
mrdwab / cSplit.R
Last active March 14, 2023 05:03
The faster version of `concat.split` that makes use of `data.table` efficiency.
cSplit <- function(indt, splitCols, sep = ",", direction = "wide",
makeEqual = NULL, fixed = TRUE, drop = TRUE,
stripWhite = FALSE) {
message("`cSplit` is now part of the 'splitstackshape' package (V1.4.0)")
## requires data.table >= 1.8.11
require(data.table)
if (!is.data.table(indt)) setDT(indt)
if (is.numeric(splitCols)) splitCols <- names(indt)[splitCols]
if (any(!vapply(indt[, splitCols, with = FALSE],
is.character, logical(1L)))) {
@aurora-mareviv
aurora-mareviv / server.R
Last active July 7, 2017 19:55
Power estimations in Mitochondrial DNA association studies: a Samuels et al. impementation (with Graph)
#under GNU General Public License
#server.R
library(shiny)
library(ggplot2)
shinyServer(function(input, output) {
## My function:
f <- function(min.cases, max.cases, p0, OR.cas.ctrl, Nh, sig.level) {