This section serves like TIL (Today I Learned) for code I wrote and often forget.. If you see error contact me via (konrad@konsta.com.pl)[mailto:konrad@konsta.com.pl].
tar --use-compress-program="pigz --best --recursive" -cf archive.tar.gz ./YourData
# Run cmd in conda env
run_cmd = function(env, cmd, wait=F){
system(paste0(". ~/.bashrc 2>/dev/null && conda activate ", env, " && ", cmd), wait = wait)
}
library(dplyr)
metadane = data.table::fread("metadata.csv") %>% mutate_if(is.character, as.factor)
library(survival)
library(lubridate)
library(ggsurvfit)
library(gtsummary)
library(tidycmprsk)
# library(condsurv)
library(ggpubr)
library(survminer)
library(dplyr)
temp = metadane
s1 <- survfit(Surv(OS_TIME, OS) ~ Cohort, data = temp)
s1 %>% tbl_survfit(times = c(12,24,60), label_header = "**{time}-month survival**" )
ggsurvplot(s1, pval = T, risk.table = T)
m = coxph(Surv(OS_TIME, OS) ~ Cohort, data = temp)
summary(m)
tbl_regression(m, exponentiate = T)
library(survminer)
library(survival)
library(gtsummary)
library(caret)
meta2 = meta[,-nearZeroVar(meta)]
univ1 = tbl_uvregression(
meta2,
method=coxph,
y = Surv(time = OS_TIME, event = OS),
exponentiate = TRUE,
include = c(-PFS, -PFS_TIME),
pvalue_fun = function(x) style_pvalue(x, digits = 3)
)
saveRDS(univ1,"univ1.RDS")
library(edgeR)
y <- DGEList(counts = counts, group = rep("Unknown", ncol(counts)))
y <- calcNormFactors(y)
# log10TPM
TPM = cpm(y,normalized.lib.sizes = F, log = F)
TPM = log10(TPM+0.001)
write.csv(TPM, "log10TPM.csv")
# TMM
TMM = cpm(y, normalized.lib.sizes = TRUE, log = T)
write.csv(data.frame("Gene"=rownames(TMM),TMM), "TMM.csv", quote = F, row.names = F)
write.table(data.frame("Gene"=rownames(TMM),TMM^2) , "TMM_for_cibersort.tsv", quote = F, sep = "\t", row.names = F)
TMM = as.matrix(TMM)
Copyright © 2022 Konrad Stawiski (konrad@konsta.com.pl; konrad@stawiski.net). Built as OmicApp by Konrad Stawiski.