Skip to content

Instantly share code, notes, and snippets.

@arraytools
arraytools / simulation_logrank_test.R
Created December 2, 2024 21:55
Compare the effects of sample size on the log-rank test
library(survival)
# Function to generate survival data
generate_data <- function(sample_size, event_rate_group1, event_rate_group2) {
group <- c(rep(1, sample_size), rep(0, sample_size))
event_times <- c(rexp(sample_size, rate = event_rate_group1),
rexp(sample_size, rate = event_rate_group2))
observed <- rep(1, sample_size * 2) # Assuming all events are observed
data <- data.frame(group = group, event_times = event_times, observed = observed)
return(data)
@arraytools
arraytools / Singularity
Last active April 20, 2024 12:05
Corrected singularity definition file for RNA-Seq analysis. The original file is available from https://hpc.nih.gov/apps/singularity.html. Especially, From: is changed to use miniconda3. I have to comment out sailfish installation.
sudo singularity build rnaseq3 rnaseq3.def
./rnaseq3 cat /etc/os-release # debian 11, host=ubuntu 2204
./rnaseq3 samtools --version # 1.10
./rnaseq3 STAR --version # 2.5.2b
./rnaseq3 fastqc -v # v0.12.1
./rnaseq3 kallisto | head 1 # 0.50.1
./rnaseq3 subread # command not found
./rnaseq3 featureCounts -v | head # v2.0.6
./rnaseq3 ls /opt/conda/bin
./rnaseq3 which gcc # 10.2.1
@arraytools
arraytools / TCGAbiolinks-GBM.Rmd
Last active March 11, 2024 00:27
This is an updated/enhanced version of [TCGAbiolinks to DESEq2](https://rpubs.com/tiagochst/TCGAbiolinks_to_DESEq2)
-3.2510638297872343 -231.0344827586207
-2.2808510638297874 -170.68965517241372
-2.612765957446809 -151.72413793103442
3.1063829787234054 246.55172413793102
3.846808510638298 246.55172413793102
2.7234042553191484 175.86206896551727
2.340425531914893 194.82758620689657
2.519148936170212 158.62068965517244
2.187234042553192 162.0689655172414
2.187234042553192 146.55172413793105
@arraytools
arraytools / dataOutliers.csv
Created March 7, 2024 19:22
Test data containing outliers
0.3114754098360656 0.4101123595505618
0.4499089253187615 0.4082397003745317
0.3460837887067396 0.5580524344569288
0.8105646630236795 0.7584269662921348
0.785063752276867 0.7584269662921348
0.7777777777777779 0.7584269662921348
0.7686703096539163 0.7584269662921348
0.7231329690346083 0.7602996254681647
0.7085610200364298 0.7602996254681647
0.6976320582877961 0.7584269662921348
@arraytools
arraytools / Install_R_RStudio.txt
Last active March 26, 2025 16:51
Install multiple versions of R and launch RStudio with different versions of R. Here I assume I'm working on a Debian desktop (Linux distro affects how R is installed and the binary version of RStudio.
# References:
# https://cran.r-project.org/bin/linux/debian/
# https://rviews.rstudio.com/2018/03/21/multiple-versions-of-r/
# 2023/12/30
sudo nano /etc/apt/sources.list # deb-src http://deb.debian.org/debian/ unstable main
sudo apt update
sudo apt build-dep r-base
wget https://cran.r-project.org/src/base/R-4/R-4.3.2.tar.gz
@arraytools
arraytools / officer-R.Rmd
Last active December 27, 2023 22:39
A demonstration of using the 'officer' R package
---
title: "Officer"
output: html_document
date: "2023-12-26"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(officer)
library(flextable)
@arraytools
arraytools / Dockerfile
Last active August 5, 2024 19:42
RenvDocker example for Docker + Shiny. See https://appsilon.com/renv-with-docker/ for more details.
# Base R Shiny image
FROM rocker/shiny
# Make a directory in the container
RUN mkdir /home/shiny-app
# Install Renv
RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))"
# Copy Renv files and Shiny app
@arraytools
arraytools / flatpak.txt
Last active November 4, 2023 13:33
flatpak installation process
$ flatpak install com.obsproject.Studio.flatpakref
Note that the directories
'/var/lib/flatpak/exports/share'
'/home/brb/.local/share/flatpak/exports/share'
are not in the search path set by the XDG_DATA_DIRS environment variable, so
applications installed by Flatpak may not appear on your desktop until the
session is restarted.
@arraytools
arraytools / resp.txt
Created September 28, 2023 19:29
respiratory data for running longitudinal data analysis. See the SAS document https://documentation.sas.com/doc/en/pgmsascdc/v_012/statug/statug_gee_examples01.htm.
center id treat sex age baseline visit1 visit2 visit3 visit4
1 1 P M 46 0 0 0 0 0
1 2 P M 28 0 0 0 0 0
1 3 A M 23 1 1 1 1 1
1 4 P M 44 1 1 1 1 0
1 5 P F 13 1 1 1 1 1
1 6 A M 34 0 0 0 0 0
1 7 P M 43 0 1 0 1 1
1 8 A M 28 0 0 0 0 0
1 9 A M 31 1 1 1 1 1