Skip to content

Instantly share code, notes, and snippets.

View aurora-mareviv's full-sized avatar

aurora-mareviv

View GitHub Profile
library(tidyverse)
library(tidytext)
library(wordcloud)
library(reshape2)
library(tidygraph)
library(ggraph)
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.
@aurora-mareviv
aurora-mareviv / server.R
Last active December 23, 2021 08:21
Simple random table generator for clinical trials - R/Shiny app
# server.R
shinyServer(function(input, output) {
f <- function(seed, ncases, branches){
set.seed(seed)
branch <- branches
if(branch==2){ # table creation
rond1 <- round(ncases/2, 0)
rond2 <- ncases-rond1
% 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 / journaltab.R
Last active August 29, 2015 14:07
Download journal abbreviations table from NCBI website
######################################
### DOWNLOAD JOURNAL ABBREVIATIONS ###
######################################
# URL: ftp://ftp.ncbi.nih.gov/pubmed/J_Medline.txt
cit <- read.csv("ftp://ftp.ncbi.nih.gov/pubmed/J_Medline.txt", quote = "", sep = "\t", row.names = NULL, stringsAsFactors = FALSE)
# Tidy the original data and create data.frame
names(cit)[1] <- "X"
@aurora-mareviv
aurora-mareviv / ifactors.R
Last active August 29, 2015 14:07
Download 2014 Impact factors from Citefactor.org
####################################
### DOWNLOAD IMPACT FACTORS 2014 ###
####################################
# url: http://www.citefactor.org/journal-impact-factor-list-2014.html
# download lots of tables, then join them
# tabs <- getURL(url)
# tabs <- readHTMLTable(tabs, stringsAsFactors = F)
library(RCurl)
@aurora-mareviv
aurora-mareviv / ReadPubMed.R
Last active September 22, 2016 23:06
ReadPubMed modified function from RefManageR
ReadPubMed <- function (query, database = "PubMed", ...)
{
.params <- list(...)
bad.ind <- which(!names(.params) %in% c("usehistory", "WebEnv",
"query_key", "retstart", "retmax", "field", "datetype",
"reldate", "mindate", "maxdate"))
.parms <- .params
if (length(bad.ind)) {
warning("Invalid .params specified and will be ignored")
.parms <- .parms[-bad.ind]