sha256 stringlengths 64 64 | language stringclasses 28
values | size int32 1 491k | lines int32 1 23.2k | content stringlengths 1 200k |
|---|---|---|---|---|
7150d9a0e118e850eeb376ef779f2d776c44be4eb292bc2188d78d19bc8a2aa8 | R | 438 | 13 | # Regression diagnostics for mids object
mids_diagnostics <- function(model, name = "") {
res <- sapply(model$analyses, residuals)
res <- apply(res, 1, mean)
fit <- sapply(model$analyses, fitted)
fit <- apply(fit, 1, mean)
res_standard <- sapply(model$analyses, rstandard)
res_standard <- apply(res_standard,... |
ecf90e9862a7604b7a1e93d6ad8f7e147d54ce3442e36f5c9047359a91b20c13 | R | 442 | 15 | #' Glioblastoma patient MGH136
#'
#' Patient data taken from the Neftel et al (2019) scRNA-seq study of 28 human glioblastomas.
#'
#' @format ## `MGH136`
#' A sparse matrix with 6,954 rows and 229 columns:
#' \describe{
#' \item{rows}{high-quality genes post-filtering}
#' \item{columns}{high-quality cells post-fil... |
ddce8b0797637c8f2a0bdc4000c9a7e1eb7201bbf7097d6ec4197843ea1e1c01 | R | 455 | 21 | library(scImpute)
t<-c('0.8','0.85','0.9','0.95')
for ( i in 1:length(t)) {
print(t[i])
root<-paste0("../datasets/sim/")
results<-paste0("../results/expression_recovery/scImpute/")
name<-paste0('data_',t[i])
name1<-paste0(t[i],'/')
scimpute(
count_path = paste0(root,name,".csv"),
infile = "csv",
... |
80ed9b3d56cabfeae70cc9e1bff920522bcd64cc786bb244c7867e04284b4f4d | R | 458 | 10 | devtools::document()
devtools::check()
devtools::build()
devtools::install_github("JCVenterInstitute/DAFi-gating", build_vignettes = FALSE, force = FALSE)
library(DAFi)
SampleData <- system.file("extdata", "sample.fcs",package="DAFi")
SampleflowFrame <- suppressWarnings(flowCore::read.FCS(SampleData))
inclusionConfig ... |
984d4bd71f565375a2a81c6601cee617aba2026ecfc6505195f3d2f4380e5102 | R | 460 | 14 | require(WhitelawCowan)
rgc.file=system.file("WhitelawCowan-2000-WT-retinal-gradients.txt",
package='WhitelawCowan')
sc.file=system.file("WhitelawCowan-2000-WT-retinal-gradients.txt",
package="WhitelawCowan")
op.file='WhitelawCowan-2000-WT-map.txt'
## We run for just a few iterations to check that everything can ... |
4822268af0bc130e6cd69cfe2e56fb9d84803e518ff5dbbe36d547ecad3cddfe | R | 461 | 17 |
dea_order = function(dea.l) {
nsig1 = sapply(dea.l, function(df) sum(df$p.adj <= 0.01, na.rm = TRUE))
nsig2 = sapply(dea.l, function(df) sum(df$p.adj <= 0.001, na.rm = TRUE))
order(nsig1, nsig2, decreasing = T)
}
dea_sort = function(dea.l, ...) {
dots = list(...)
ord = dea_order(dea.l)
dea.l =... |
c655aac65bf471aaa69509a8bf4f7e0b95ebdc46bce6ef2c01954235d2e094e8 | R | 462 | 17 | #' @examples
#' File format:
#' pdc,cor
#' 0610009B22Rik@peak217336,0.0602667683204699
#' 0610009B22Rik@peak217343,-0.0929365338771179
#' @export
loadCor <- function(f, split = "@") {
r <- data.table::fread(file = f, header = TRUE, sep = ",",
data.table = FALSE)
gene.peak <- vapply(r$pdc, function(i) {
t <... |
ccdd4b707c8669a43e3c67d26c986115dece681c89278faba879e9b49c2cf3a5 | R | 462 | 7 | #' scRNA-seq data from a patient with Glioblastoma
#'
#' A single-cell RNA-sequencing dataset containing 8556 HQ genes and 1265 high quality cells. The data was generated using the Smart-Seq2 protocol and was analysed in the form log2(TPM/10 + 1).
#'
#' @format A matrix with 8556 genes (rows) and 1265 cells (columns):
... |
58872f22934b32eaf2551b305de6d687031009dc53616732da29ffa107d0ce10 | R | 466 | 10 | #' scPOP: Metrics for Benchmarking scRNA-Seq Batch Correction
#'
#' Evaluate using batch effect correction for scRNA-seq using multiple established methods, including the Adjusted Rand Index,
#' Normalized Mutual Information, Local Inverse Simpson Index, and Silhouette Width. We also included metrics for #' aggregatin... |
68b9d1ad719e5c3b539a6b664d4a30c49e24dce9c42d7eebb7e369a519dc3c4b | R | 472 | 28 | # this file is the first part for getting pvalue cutoff for FDR 0.05
# sort the p values based on true data; O(nlogn)
# load pvalues based on true data
data_dir = "../../data/intermediate_data/"
pvalues_rds = readRDS(paste0(data_dir, "pvalues_big_list.rds"))
pvalues = unlist(pvalues_rds)
pvalues_ordered = sort(pv... |
383928f0f4060ee70185ba7d5e912b740c3a952f467997816ed616a8242c477a | R | 480 | 15 |
#' @title FUNCTION_TITLE
#' @description FUNCTION_DESCRIPTION
#' @param pattern PARAM_DESCRIPTION
#' @param signatures PARAM_DESCRIPTION, Default: scalop::NormalSignatures
#' @return OUTPUT_DESCRIPTION
#' @details DETAILS
#' @seealso
#' \code{\link[stringr]{str_detect}}
#' @rdname get_signatures
#' @export
#' @impo... |
f0ad81c34c11ef53557e980a4d39a4d05867e833528ce0d47549aa4562de1f74 | R | 481 | 12 | fisherCorrection = function(fc){
#Adding a tiny value to zero/Inf odds ratios (zeros become Inf's when log converted)
fc = as.data.frame(fc)
fc$or = ifelse(test = is.infinite(fc$or), yes = fc$ci.up, no = fc$or )
fc$or = ifelse(test = fc$or == 0, yes = fc$ci.low, no = fc$or)
fc$ci.low = ifelse(test = fc$ci.l... |
6c5a8f4fbf8ed740f981333fac828c4a152330728fba311c33e8b28f79306581 | R | 485 | 17 | # odds ratios for loy in full model
# read in model from figure5.R
mod <- readRDS(here("ckd","figures","jmod4.rds"))
plotA <- plot_model(mod, p.adjust=TRUE)
plotA <- plotA +
ggtitle("A)") +
geom_hline(yintercept = 1, linetype = "dotted") +
theme_bw() +
theme(plot.title = element_text(face="bold"), axis.tex... |
c5898c9fc80e4a43164bae948398f4d42ebecb1aac583bc09c9878f1275ba243 | R | 489 | 13 |
cmdargs <- c("-m","mask.nii.gz",
"--set1", "setfilenames1.txt",
"--set2", "setfilenames2.txt",
"--setlabels1", "setlabels1.csv",
"--setlabels2", "setlabels2.csv",
"--model", "nlmemodel.permute.R",
"--testvoxel", "10000",
... |
353b3bf75bb226cd310693968f009aa9976f00ba99bafa4536dd778000b9d6db | R | 491 | 20 | # bypass R CMD Check notes, related to tidyverse non-standard evaluation
# https://www.r-bloggers.com/2019/08/no-visible-binding-for-global-variable/
utils::globalVariables(c(
".",
"CellType",
"Gene",
"MGI_symbol",
"Species",
"Specificity",
"Study",
"Study_species",
"data",
"desc",
"ensembl_gene_i... |
2571efbff54a266c16ba0ac13ed857b7ffa3286a00c5611381439329a20ad728 | R | 494 | 16 | # install packages
BiocManager::install("RNAAgeCalc")
library(RNAAgeCalc)
# define arguments
expression_data <- args[1]
tissue_type <- args[2]
population <- args[3]
out_dir <- args[4]
# load in expression data
exprdata <- read.table(expression_data)
# run the program and save the text file
res = predict_age(exp... |
37e3f51fc8082cd6ef2502e2beccfd9210140a32b6ba45571a5355caf913be6b | R | 512 | 26 | source('GOEA.R')
filecomm='../Communities/Networks02/W45fastgreedy.txt'
thresh=80
AAA=read.delim(filecomm)
uc=unique(AAA$Community.Id)
nuc=length(uc)
universe=as.vector(AAA$mgi_symbol)
results=NULL
for (i in c(1:nuc)){
dum=which(AAA$Community.Id%in%uc[i])
ld=length(dum)
if(ld>=thresh){
print(i)
group= universe... |
c8d70c4662c81faa23c31badd61f5f31dd003039ff0a620648ddd5ed474f5e7c | R | 512 | 14 | require(Seurat)
snapshot <- "/lab-share/RC-Data-Science-e2/Public/DST_software/pipeline_R_snapshot/r4.1-20220803-bch-dst-v1/"
.libPaths(snapshot)
source('/lab-share/RC-Data-Science-e2/Public/Daniel/rFunctions.R')
library(rBCS)
# Setting WD
setwd('/lab-share/RC-Data-Science-e2/Public/Daniel/p147-scRNAseq-Koehler')
# L... |
91d349b2230bb4792a8f0f0221756541a9fe75c93c74e50069e1ad9fd47229a8 | R | 515 | 28 | #
# Example Rscript command
# for testing
#
main <- function() {
cat (' ### R.Version() ### \n');
print(R.Version());
cat (' ### sessionInfo() ### \n');
print(sessionInfo());
cat (' ### .libPaths() ### \n');
print(.libPaths());
# cat (' ### Sys.getenv() ### \n');
# Sys.getenv();
# #... |
445411133499c27e2bb51bcee7a3aa69de51a31446aa567c9bbf8990517e3352 | R | 520 | 12 |
#' @title Set the rownames in an object
#' @description This is a convenience function that sets the rownames on an object, in the same manner as stats::setNames
#' @param object an object for which a ‘rownames’ attribute will be meaningful. Default: nm
#' @param nm a character vector of rownames to assign to the obje... |
f778eaa7a3fc3328434c82f67ed8f1e80cc3366078f61c1dcf874fb746d43e6c | R | 520 | 12 |
#' @title Set the colnames in an object
#' @description This is a convenience function that sets the colnames on an object, in the same manner as stats::setNames
#' @param object an object for which a ‘colnames’ attribute will be meaningful. Default: nm
#' @param nm a character vector of colnames to assign to the obje... |
71b64bf2dfae1becd4d1bb852f97114ed73466f3501756ef1b1a928c0ebd11c7 | R | 528 | 16 |
#' @title Row Means of Log2 data
#' @description calculate row means in normal space and then convert back to log2.
#' @param x numeric matrix
#' @param type how was the data normalised? "tpm"; Transcripts Per Million. "cpm"; Counts Per Million. Default: "tpm"
#' @return vector of log2 row means
#' @rdname logRowMea... |
10280d0b86742b7e0f2a6069048c00eead308633e0ad962656925dbd4ec97cd5 | R | 531 | 18 |
library(ggplot2)
pos_file = "../data/intermediate_data/t12_HLA_I_associated_TCR_v_alleles.csv"
df_pos = read.csv(pos_file, header = TRUE)
dim(df_pos)
head(df_pos)
df_freq = data.frame(table(df_pos$hla_allele))
df_freq[order(df_freq$Freq, decreasing = TRUE), ]
p1 <- ggplot(df_freq, aes(x=Freq))+
geom_histogram... |
7e2d5cd03df86a73c7150d45f62bb82d0be118ea91cc4a852a2148024a3d0da4 | R | 536 | 13 | #' Example scRNA-seq data from the single cell eye in a disk(sceiad)
#' the original data set this was pulled from can be found at this link
#' 'https://hpc.nih.gov/~mcgaugheyd/scEiaD/colab/scEiaD_all_anndata_mini_ref.h5ad'
#'
#' @docType data
#' @usage data(sceiad_subset_data)
#' @format An object of class \code{"data... |
85da7c7ca92a1fb760ad2aacbac2db40b0e892330ae4047594c54b2fe888c474 | R | 542 | 18 | #' Obtain the index diseases from a \code{comoRbidity} object
#'
#' Given an object of type \code{comoRbidity}, extract the index diseases
#' present in the data.
#'
#' @param input An object of class \code{comoRbidity}
#' @return A list with the index diseases present in the input data
#' @examples
#' indexDis <- ext... |
527ad3482c8744442ca55d9b19decf3acf7c3fe71112478d8161ce8357c34598 | R | 543 | 17 | #' @import ape
#' @import microeco
#' @importFrom magrittr %<>%
#' @importFrom magrittr %>%
#' @importFrom utils data
#' @importFrom utils read.csv
#' @importFrom utils read.delim
#' @importFrom utils read.table
#' @importFrom yaml read_yaml
#' @importFrom rhdf5 h5read
#' @importFrom Matrix sparseMatrix
#' @importFrom... |
befb063871d1dde720cb56adb6598148879d11e44c1edc0953f25973147f6589 | R | 546 | 25 | #!/usr/bin/env Rscript
args <- commandArgs(TRUE)
stopifnot(length(args)==1)
paramfile <- args[1]
source(paramfile)
## Divert everything else now to the output file; this taken from sink() help page.
zz <- file(sprintf("%s-output.log", paramfile), open="wt")
sink(zz)
sink(zz, type="message")
## Do as much as we can ... |
7edba758abf9380806db9b707913cd55910d9590d91947468cf28fc793568472 | R | 557 | 16 | #!/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
main_f <- as.character(args[1])
track <- as.character(args[2])
config_f <- as.character(args[3])
descr <- as.character(args[4])
import_adj <- as.logical(args[5])
source(paste0(main_f,'config.R'))
setwd(paste0(map3c_f,'/map3c/'))
Sys.setenv(PIPELINE_HOME = map3... |
c29849380cf284379d3ca4cd69e153608f65932992cfbc2627a5c00671e86207 | R | 572 | 13 | cmdargs <- c("-m","mask.nii.gz", "--set1", "setfilenames1.txt",
"--set2", "setfilenames2.txt",
"--set3", "setfilenames3.txt",
"--setlabels1", "setlabels1.csv",
"--setlabels2", "setlabels2.csv",
"--setlabels3", "setlabels3.csv",
... |
6185d40e5b7ec8dce534df7438e50503a4ccb86a56e68437cb642209849f4229 | R | 573 | 15 | ## For lmmp data, make table with specific genes for each cluster
library(here)
library(tidyverse)
library(monocle3)
lmmp <- readRDS("6month_LMMP.rds")
tm <- monocle3::top_markers(lmmp, group_cells_by = "cell_type_factor", genes_to_test_per_group = 30, cores = 16 )
col_to_keep <- c("cell_group","gene_id","gene_shor... |
09601dccebe8021f2c070e65b818209c0ed4d6eb9c9065ce0dac8f25f2988754 | R | 574 | 25 | library(here)
library(tidyverse)
## main Seurat package snRNA-seq pacakges
library(Seurat)
library(SeuratDisk)
library(future)
## tree specific functions
library(ggtree)
library(treeio)
library(ggtreeExtra)
library(tidytree)
## for importing python to R
library(reticulate)
pd <- import("pandas")
DATADIR='data/tidy_... |
1bd2113d1b1ea8f003b696d48996c3efc7b9e0eac65672c84c408c0564534cce | R | 575 | 23 | # odds ratios for loy by cell type in multiomes
library(here)
library(ggplot2)
library(sjPlot)
plots <- here("ckd","figures")
# read in model from figure5.R
mod <- readRDS(here(plots,"multiomes_mod2.rds"))
plotA <- plot_model(mod, p.adjust=TRUE)
plotA <- plotA +
ggtitle("A)") +
geom_hline(yintercept = 1, line... |
d199a998625528c53e941b0656e95fc68eb4ad8b4144050d09f51051e720f95a | R | 578 | 16 | # this script works after you have git cloned https://github.com/gemmashireby/CorticalClock
# arguments
clock_directory <- args[1]
beta_matrix <- args[2] # rownames=cpgs, colnames=IDs
phenotype_file <- args[3]
phenotype_ids <- args[4]
phenotype_ages <- args[5]
out_dir <- args[6]
# source the cortical clock script... |
47437fd1b59e87d754bb6dd6b3f3a6507a6561d132048c75af93c2e196983cae | R | 581 | 16 | snapshot <- "/lab-share/RC-Data-Science-e2/Public/DST_software/pipeline_R_snapshot/r4.1-20220803-bch-dst-v1/"
.libPaths(snapshot)
source('/lab-share/RC-Data-Science-e2/Public/Daniel/rFunctions.R')
library(Seurat)
library(SeuratDisk)
# Set WD
setwd('/lab-share/RC-Data-Science-e2/Public/Daniel/p147-scRNAseq-Koehler')
#... |
d5edeb2c666335bc3a30a09290af0e57bef60c36e13f88bdb71a24f03b855816 | R | 585 | 20 | manually_define_clusters = function(hclust_obj, data_matrix) {
plot(as.hclust(hclust_obj), labels=F, sub="", xlab="")
myClusters <- identify(as.hclust(hclust_obj), N=200, MAXCLUSTER=length(hclust_obj$order))
dirname = paste("manually_defined_clusters_", length(myClusters), sep='')
dir.create(dirname)
for (... |
22aa630ed16594ec15043c1bcfc2259a929fcf7f701c7d84fbe29b7a1037f2b1 | R | 594 | 12 | #' @title Convert logCPM to CPM
#' @description Convert logCPM to CPM, i.e. using 10*(2^(CPM)-1).
#' @param m matrix of logCPM values (gene rows; cell columns)
#' @param bulk if bulk then instead uses 2^(CPM)-1. i.e. no scaling. Default: F
#' @return CPM matrix
#' @details CPM/10 is used for single cells since 100,00... |
d56c704aba05a8cab505d49d83aca4e455a4496e955eebb7dfe7482c4927d054 | R | 594 | 12 | #' @title Convert CPM to logCPM
#' @description Convert CPM to logCPM, i.e. using log2(CPM/10 + 1).
#' @param m matrix of CPM values (gene rows; cell columns)
#' @param bulk if bulk then instead uses log2(CPM + 1). i.e. no scaling. Default: F
#' @return logCPM matrix
#' @details CPM/10 is used for single cells since ... |
3410ceb5bc9910ec55301dd94bfda014534d4e37434346dad1698f904796b86f | R | 617 | 13 | library(dplyr)
df_macrophage_props <- read.csv("macrophage_props_1dpi_and_5dpi.csv")
df_macrophage_props
df_fishID_props <- df_macrophage_props %>% group_by(short_name, time_point) %>% summarize(fish_id = fish_id[1], mean_area = mean(Area, na.rm = TRUE), time_in_h = min(time_in_h), dpi = dpi[1], macrophage_count = ... |
6849d61d69dd53b795a51d8e18cc2cecee3982db7e633aa2d1b0567610fc4a38 | R | 617 | 17 |
#' @title Select top n elements
#' @description ntop() returns the top 'n' elements of a vector or per vector in a list.
#' @param x A vector or list.
#' @param n Number of elements to return.
#' @param remove.lower Remove vectors that have fewer than 'n' elements. Default: FALSE
#' @return A vector or list of the sa... |
b1f7602bc5ae76ffb2a59cc0b5872e2342bbb2709bb977dd9a4b32997646edc7 | R | 619 | 27 | ##### Config parser #####
# only works for INI file
#
# 20 Dec 2016
# Kyoko Watanabe
#########################
ConfigParser <- function(file){
line = as.character(read.table(file, header=F, sep="\t")[,1])
i=0
config <- list()
for(l in line){
l = gsub(" ","", l)
if(grepl("\\[.*\\]", l)){
i <- i+1
... |
2f5bc0b685a7fb351ad174ca13a2bc62b426ce1f752901aa5ed7a4ddbd89dfd4 | R | 623 | 21 | # O2: use interactive job with 20G RAM
# sometimes Rscript is not working but works from R
# conda activate r
# which R
# Rscript 00_create_seurat_object.R
# conda deactivate
# should have 3 files from bcbio
library(R.utils)
file.rename("tagcounts.mtx", "matrix.mtx")
file.rename("tagcounts.mtx.rownames", "features.tsv... |
eb4fc65f304511be70d53e79cb26517d59e60bb6b0f1d55b032973c244863ba0 | R | 627 | 17 | # show marginal effects for all cell types
jmod4 <- readRDS(here("ckd","figures","jmod4.rds"))
# subset factor levels in plots
plotA <- plot_model(jmod4, type = "emm", terms = c("scaled_cnv","celltype"))
plotA <- plotA + theme_bw() + ggtitle("A)") +
theme(legend.title=element_blank(),
legend.pos=c(0.2,0.... |
fa4ee5ee5223b737f2c34e845b18084011624b639c123fb23dc2df8adbef0691 | R | 644 | 32 | # make mutation and CNV data deterministic
library(tidyverse)
library(fs)
source("scripts/utils.R")
samples_metastatic <-
read_csv(MOUNTED_FILES$labels, col_types = "ci") %>%
filter(response == 1L) %>%
pull(id)
mutations <- read_csv(MOUNTED_FILES$mutations)
mutations %>%
mutate(
across(!1, ~as.integer... |
267006cd03ccee4097b3dcf2b5bf2bd5817383a30624cb8016de8313d59a1834 | R | 658 | 15 | #' @title Convert TPM to logTPM
#' @description Convert TPM to logTPM, i.e. using log2(TPM/10 + 1).
#' @param m matrix of logTPM values (gene rows; cell columns)
#' @param bulk if bulk then instead uses log2(TPM + 1). i.e. no scaling. Default: F
#' @return TPM matrix
#' @details TPM/10 is used for single cells since ... |
f2d91fdbb7b4851a65ea3cd00f31f1aa2f4af335eaf966e034761639979af4f3 | R | 662 | 37 | # Gregory Way 2017
# PanCancer Classifier
# install.R
#
# Initializes all the R package versioning for use in the PanCancer pipeline
#
# Usage: Run once at the onset of development or reproduction
#
# Rscript --vanilla scripts/install.R
library("methods")
library("checkpoint")
dir.create(".checkpoint")
checkpoint... |
d0a7e166e461250130f9956e6eb7d4fbc7831c02ec8212aed9d79c0b517898dc | R | 667 | 21 | #' Prints available TCGA datasets
#'
#' @description Prints available TCGA cohorts
#' @param repo can be "github" (default) or "gitee". If `github` fails to fetch, switch to `gitee`
#' @examples
#' tcgaAvailable()
#' @export
#' @seealso \code{\link{tcgaLoad}}
tcgaAvailable = function(repo = c("github", "gitee")){
rep... |
f1f265fcbc73e0be3a88fc040f7ff3e7fe54fd9b77c882cf457aa5db8394dd5e | R | 673 | 17 | #' Table of Human-->Mouse orthologs for all human genes
#'
#' A dataset containing mouse orthologs of human genes.
#'
#' @format A data frame with nine variables:
#' \describe{
#' \item{\code{ensembl_gene_id}}{Human ensembl id}
#' \item{\code{hgnc_symbol}}{HGNC symbol}
#' \item{\code{entrezgene}}{Human NCBI gene ID}
#'... |
298b2f09cf36233193c72cd23cf4e12c50c7d8eeb5faf13ef39fcc9f2815738e | R | 680 | 18 | #############################################################
# Generate 3D simulations for 3D vs 2D meta-analysis comparision
#############################################################
InputDir <- "..\\Data\\3D_Standard_Sim\\"
OutputDir <- "..\\Data\\3D_Standard_Sim_2DSlice\\"
InputFiles <- list.files(Inpu... |
7c6ac6846f9d05e7e5755621ab768c3fc2c936e091b794961db3f031c2773f73 | R | 684 | 26 | Find_equal <- function(df1, df2){
ordered_df1 <- df1[order(df1[,1]),]
ordered_df2 <- df2[order(df2[,1]),]
vector1 <- ordered_df1[,4]
vector2 <- ordered_df2[,4]
compartment <- rep(NA, length(vector1))
for (i in 1:length(vector1)) {
if(vector1[i] == vector2[i] ){
compartment[i] <- vector1[i]
}
... |
c81ef896ec4d5ba89ee706085de16521c487043577455e032af9bd193759b320 | R | 688 | 28 | source("../misc_rnaseq_funcs.R")
source("../heatmap.3.R")
data = mtcars;
data = log2(data*10+1)
scale(data,center=T,scale=T); # Z-scores
## Use principal components to partition the 'genes'
pc = princomp(data, cor=T)
pc4 = pc$scores[,1:4]
pc4_cols = matrix_to_color_assignments(pc4)
colnames(pc4_cols) = paste("PC", ... |
a48369fdd6f5b6f342be83f918211c6d6ec6c62580d6bad4fcada19a71945ff9 | R | 692 | 19 | #' Log(CP10k+1) normalized counts matrix (genes by cells) for 10x PBMCs dataset for vignette.
#'
#' @format: Sparse matrix (dgCMatrix): dimensions 1,764 genes by 1,200 cells
"pbmcs_exprs_small"
#' Metadata for 10x PBMCs dataset for vignette.
#'
#' @format: A data frame with 1,200 cells and 7 metadata fields.
#' \de... |
a150ff80eef8dec4bd4004a7da7cf945fa3e533f4687a17aea14a14771bb3a13 | R | 693 | 16 | library(data.table)
counts <- fread("compiled_counts_455_10182021.csv")
for(i in 3:14){
counts[[i]] <- round((counts[[i]]/sum(counts[[i]]))*1e6,0)
}
#We sum just the DNA counts and the input for this
corrcounts <- cbind(counts[,1:8],
fread("input1_corrected.txt")[,4],
fread("input2_cor... |
4e3d2a9194f7d109807474b661df35fd0acecab453b0a916dc5e6f1fca305cf7 | R | 696 | 12 |
# Load in gifti files with S-A axis ranks in fsaverage5 from Val's github repo
SA_axis_gii_L<-read_gifti('/Users/askeller/Documents/Kellernet_PrelimAnalysis/SpinTests/SensorimotorAssociation_Axis_LH.fsaverage5.func.gii')
SA_axis_gii_R<-read_gifti('/Users/askeller/Documents/Kellernet_PrelimAnalysis/SpinTests/Sensorimot... |
15978d26b803584fb65e78190a75f5c904304c2ac67d67355f07f664ca384f4e | R | 699 | 28 | # scatterplot between predicted expression from sequence and observed expression
args<-commandArgs(trailingOnly=T)
cal_cor<-function(cvfile) {
d<-read.table(cvfile, stringsAsFactors=F)
svr<-d[[2]]
expr<-d[[3]]
cor(svr, expr)
}
expids<-c("Melnikov2012/processed/mtsa_mel12.m1000.t5.e5",
"Kher... |
c1995679ebbf0553b94a1915e4d4493c9233af405c027addacb32b944f6fc73a | R | 704 | 34 | .is_grob <- function(x) {
'grob' %in% class(x)
}
.which_to_grob <- function(x) {
sapply(x, function(i) !is_grob(i))
}
.add_rows <- function(Grob, n) {
if (n < 1) {return(Grob)}
for (i in 1:n) {
Grob <- gtable::gtable_add_rows(Grob, unit(0, "null"))
}
Grob
}
.add_cols <- function(Gr... |
6530d146cf5507578cf1c87b63df627a423fc911ea8a587f463c6144dcd88baa | R | 708 | 17 | setwd("/Users/alanx/Downloads/fastqc_raw/multiqc_data")
library(gtools)
raw <- read.table("multiqc_fastqc.txt", sep = "\t", header = TRUE)
raw <- raw[mixedorder(raw$Sample),]
raw <- raw[seq(1,nrow(raw), by = 2), ]
setwd("/Users/alanx/Downloads/Star/multiqc_data")
star <- read.table("multiqc_star.txt", header ... |
1965c48b0016e25b80c153935f2e6106f96a8ecd1fc5415f135a6e40ed70675f | R | 717 | 23 | #' Remove stop codons
#'
#' @param seqs list of DNA sequences in seqinr(?) format (e.g., `seqinr::read.fasta`)
#'
cutstops <- function(seqs, fastapath=NULL) {
if (!is.null(fastapath)) {
seqs <- multi2single(fastapath)
}
# Check if codons
id <- sapply(seqs, function(x) {
all((sapply(x, nchar) %% 3) == 0)
})
... |
4635efd123094211626d9c82615c17a7c7fda5ef13bf7faa8223b85df24ee6a6 | R | 718 | 26 | library(tidyverse)
d<-read_tsv('SuppData2.txt')
d2 <-d %>%
group_by(CRE) %>%
summarise(ntags=n()) %>%
filter(ntags>3) %>%
inner_join(d)
d2 <- d2 %>% mutate(log2expr = log2(d2$Exp_Mean))
d3 <- d2 %>% group_by(CRE) %>%
summarise(mean_log2expr = mean(log2expr)) %>%
inner_join(d2) %>%
muta... |
00939dac6c06de8874ef4a98f081aac64b11b612f7ccecf0c5b7800163e6bc30 | R | 723 | 22 | #' draw an oncostrip similar to cBioportal oncoprinter output.
#' @details This is just a wrapper around \code{\link{oncoplot}} with drawRowBar and drawColBar set to FALSE
#'
#' @param maf an \code{\link{MAF}} object generated by \code{read.maf}
#' @param ... arguments passed \code{\link{oncoplot}}
#' @return None.
#... |
b43b2d2ca922a07cee4fa325b98f4bed28421021388af2d4d7af02a7b1f3c954 | R | 725 | 28 | # SO answer by Hong Ooi:
# r-pass-optional-arguments-to-nested-functions
#' @title FUNCTION_TITLE
#' @description FUNCTION_DESCRIPTION
#' @param mod PARAM_DESCRIPTION
#' @param formula PARAM_DESCRIPTION
#' @param data PARAM_DESCRIPTION
#' @param ... PARAM_DESCRIPTION
#' @return OUTPUT_DESCRIPTION
#' @details DETAILS
#'... |
b85e8078f4a4168261f60494d6b2b767345dc6af322660716bfcc95d48908fde | R | 741 | 28 | library(ggplot2)
theme.no.axis <- theme(
axis.text = ggplot2::element_blank(),
axis.title = ggplot2::element_blank(),
axis.ticks = ggplot2::element_blank(),
panel.border = ggplot2::element_blank(),
panel.background = element_blank(),
plot.margin = unit(c(0,0,0,0), "cm"),
legend.title = element_text(size... |
7a6ed12691c6608c7615ad035b5c309f8898e908a3b6e720a82ee07084588779 | R | 743 | 28 | library(tidyverse)
library(rlang)
library(R6)
Sys.setenv("_R_USE_PIPEBIND_" = TRUE)
library(data.table)
library(GenomicRanges)
library(S4Vectors)
rdir <- file.path(here::here(), "package/R")
import::from(.from = "cembav2env.R", .directory = rdir,
cembav2env, Sa2PeakCalling)
import::from(.from = "peak.R", .directory... |
02e05be27bc4d7ed1131bd578291ce9e0312ea238ca43c6110f69f9741ddbe57 | R | 747 | 29 | "cohen.ES" <-
function(test=c("p","t","r","anov","chisq","f2"),size=c("small","medium","large")){
test <- match.arg(test)
size <- match.arg(size)
ntest <- switch(test, p = 1, t = 2,r=3,anov=4,chisq=5,f2=6)
if(ntest==1){
ES<-switch(size,small=0.2,medium=0.5,large=0.8)
}
if(ntest==2){
ES<-switch(size,small=0.2,medium=0.5... |
4161f2ccb071c6e92bf51a592064afee9fa0990056efeaea752155f14a6c3d61 | R | 757 | 20 | library(data.table)
library(tidyverse)
library(LncFinder)
#Read in the fasta
f <- fread("mr_asd3utr_reference_05052020.fa",header=FALSE)
#Split into two columns
f <- data.table("Elements"=f$V1[seq(1,19488,2)],"Seqs"=f$V1[seq(2,19488,2)])
#Tack on the rest of the plasmid sequence to the polyA signal
f$Seqs <- pa... |
f18ede71ee97a3efbe9d79b6b4b3af6ad1a19937bb42c02a2b1ced228096d971 | R | 771 | 18 |
#' @title Join a dataframe and a named vector
#' @description FUNCTION_DESCRIPTION
#' @param dat dataframe
#' @param vec named vector whose names are a column of the dataframe
#' @param by the name of the column that joining should be performed on.
#' @param newcol the name of the new column to add from vec. Default:... |
cf841f0cefb3af8e234a5e1595b7dd998b84a9a76c388ad93a0749278a998399 | R | 778 | 18 | library(Homo.sapiens) # package from Bioconductor.
gtf_url <- 'ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_32/gencode.v32.annotation.gtf.gz'
txdb <- makeTxDbFromGFF(gtf_url)
# TSS.
promoter_df <- as.data.frame(promoters(txdb, 0, 1))
promoter_bed <- promoter_df[c('seqnames', 'start', 'end', 'tx_nam... |
dc675369b192fa4a4b542db5528c6b60be5f0dcaf58e12953a83fdfa76510426 | R | 779 | 40 |
#' @title Filter List By Jaccard
#' @description *********
#' @param x PARAM_DESCRIPTION
#' @param threshold PARAM_DESCRIPTION, Default: 0.7
#' @return OUTPUT_DESCRIPTION
#' @details DETAILS
#' @examples
#' \dontrun{
#' if(interactive()){
#' #EXAMPLE1
#' }
#' }
#' @rdname jacFilt
#' @export
jacFilt = function(x... |
75be43dc89d6cb74c7833575550a9d13a0913c87ddfb6dd68efb232ccade06ce | R | 784 | 45 | ---
title: "p20_neuro_analysis"
author: "Jared Slosberg"
date: "5/20/2022"
output:
html_document:
code_folding: hide
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(here)
library(monocle3)
library(tidyverse)
source(here("scripts/accessory_functions/monocle_mods.R"))
sour... |
17b207260fbf33335b9d7ae4ed8f000f5be8741f96e38edcdd86d653c1e6fc1e | R | 788 | 16 | #' @title Drop rows whose names match a pattern
#' @description row_exclude() is a wrapper around m[!str_detect(rownames(m), pattern), ]. Equivalent to row_subset() with negate = TRUE.
#' @param m Input matrix or data frame.
#' @param pattern Pattern to look for. The default interpretation is a regular expression, as d... |
376085d69169f2a682965bcb3cfded8ef054ec5ea0c8151a9f70347bcf0a9ec8 | R | 788 | 38 | jaccard_dist_matrix = function(x, by.row = F) {
x = as.matrix(x);
if (by.row == F) {
x = t(x)
}
m = matrix(nrow=nrow(x), ncol=nrow(x));
diag(m) = 0;
colnames(m) = rownames(x);
rownames(m) = rownames(x);
# operates by rows.
for (i in 1:(nrow(x)-1)) {
... |
4af48580fc1a665b6a7b44df1edad4c21fff732a8c68922ceded575ebd90bfc2 | R | 790 | 28 | library(argparse)
suppressMessages(library(Seurat))
suppressMessages(library(Signac))
parser <- ArgumentParser(description = "process input arguments")
parser$add_argument("--rds", action = "store",
help = "path to rds object to compute gene activity for")
parser$add_argument("--out", action = "store",
help = "where... |
a9b5d21ca1fa39cdcec8723f03947f05716f31dae75c0ec4362399195cfc01b0 | R | 790 | 19 |
#' @title Unlist, keeping original list or element names
#' @description Unlist, keeping original list or element names
#' @param L list to flatten
#' @param nested.names logical; keep nested list names rather than expanding list names. Default: FALSE
#' @return a vector of the same length as the combined lengths of l... |
611498ca1ea20d4f8f610fe4a17b6e2a054f490c5c7cc572aacd73bfabe53846 | R | 791 | 16 | #' @title Drop columns whose names match a pattern
#' @description col_exclude() is a wrapper around m[, !str_detect(colnames(m), pattern)]. Equivalent to col_subset() with negate = TRUE.
#' @param m Input matrix or data frame.
#' @param pattern Pattern to look for. The default interpretation is a regular expression, a... |
f80e62a314962dd1bedb2dac081c6469c3aa5ea839c48b0281ca4a828f8c258e | R | 791 | 24 | library(ggplot2)
df = read.csv("../results/st2_allelewise_auc_ensemble.csv", header = TRUE)
df_reformat = data.frame(hla = c(df$hla, df$hla),
auc = c(df$depth_mcpas, df$glazer_server),
model = c(rep("DePTH McPAS", 10), rep("CLAIRE", 10)))
df_reformat$model <- fact... |
031529e0221d496f3b42ad30fdea6afcbf24db17a424a2f8dc6db40daaae8fd8 | R | 794 | 21 | #!/usr/bin/env Rscript
#####################################################################################################
# Run FCSTrans
# Note: ipconvert([FCS file directory path without trailing "/"])
#####################################################################################################
args=comman... |
53fadb6cc56d866394c1ee9f0a9e127d1319be5e17ff3ea3c72659bebd0e2f9a | R | 795 | 17 |
library(microbiome)
# filter data
ps_all <- phyloseq(otu_table(CDtaxa_All_only_s, taxa_are_rows=F),
sample_data(CDmeta_All),
tax_table(CDtaxatbl_All)) %>%
aggregate_rare(level = "species", detection = .1/100, prevalence = 10/100)
ps_hc <- prune_samples(samples=CDmeta_All[C... |
096acbcda56471b2e1edee776155f6f61328564cd293d4711b55173251d544d0 | R | 797 | 17 | ## Author: Youtao Lu <luyoutao@sas.upenn.edu>
## Copyright (c) 2017-2023, Youtao Lu and Junhyong Kim, Department of Biology, University of Pennsylvania
## Copyright (c) 2017-2023, James Eberwine, Perelman School of Medicine, University of Pennsylvania
## All Rights Reserved.
## This Source Code Form is subject to th... |
ac01c492d37e6d940224e6d6ae774518291ba6d6abdcb5652f086fb13ec8b0a6 | R | 799 | 16 |
# this function was taken from calibrate package
textxy = function(X, Y, labs, m = c(0, 0), cex = 0.5, offset = 0.8, ...) {
posXposY <- ((X >= m[1]) & ((Y >= m[2])))
posXnegY <- ((X >= m[1]) & ((Y < m[2])))
negXposY <- ((X < m[1]) & ((Y >= m[2])))
negXnegY <- ((X < m[1]) & ((Y < m[2])))
if (sum(posXposY) > 0)
t... |
c1426d91168b33080bfed3a1063d93b9eeec744b5fe69b92fa422fb5398ff555 | R | 799 | 18 | ##############################################################################
#This code will merge a selected list of genes in "nmeth.3549-S8.txt", with the data in your input data file "GSE64016_H1andFUCCI_normalized_EC.csv". The output is stored in "mergedH1.csv"
####################################################... |
678a4db14609591741cd61d907d0040243ec4fbea81628f74c7c94a3b16ebb5e | R | 801 | 18 |
GenesDescr =read.table(genedet,sep='\t',header=TRUE, quote="")
mygeneUniverse = as.vector(GenesDescr[,1])
myselectedGenes=sample(mygeneUniverse,10)
library(biomaRt)
mart <- useMart(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")
results <- getBM(attributes = c("refseq_dna", "go_molecular_function_id",
... |
78d19109dd63eaca93e47c0fa232eddd89ed76e83cdd9aaf9855d3882db679fe | R | 808 | 18 | #' @title Subtract POSIXt Class Objects in HH:MM:SS Format
#' @description subtract POSIXt class objects and return value in HH:MM:SS format.
#' @param start old Sys.time()
#' @param end new Sys.time()
#' @return subtracted time in hh:mm:ss format
#' @details source: https://stackoverflow.com/questions/32100133/print-... |
f6e75b4b8e1878eb7405628fd350c177665d53ecbdd5fc363beedaa0a60c4bf4 | R | 809 | 22 | ##C:\Users\50246\Desktop\scratch\03.weiqi\figure\total_mutaion
library(ggplot2)
library(plyr)
library("ggsci")
bar.data<- read.table("mm10.txt",sep= '',header=T)
data1= ddply(bar.data,"group",transform,Percent=num/sum(num) * 100)
p2<- ggplot(data1,aes(x=group, y=Percent,
fill = factor(base,levels= c('AG','AT','AC'... |
0d8e397abcb985a001ddcc4b2e879fb81e62a8305e69ddcd94cf16dee7635573 | R | 813 | 25 | # Merge all permutation files into one file
library(tidyverse)
library(glue)
path <- "bids/derivatives/meg-derivatives/grand_ave/brain-space/visual_model/permutations/temporal-cross/{level}/"
path_save <- "bids/derivatives/meg-derivatives/grand_ave/brain-space/visual_model/permutations/temporal-cross/{level}_tc_perm_m... |
db324cc24b81648e4a6456a43b2f56c2d349501d867518db91a85bb393f8829f | R | 814 | 23 | library(ggplot2)
df = read.csv("../results/st14_allelewise_auc_single.csv", header = TRUE)
df_reformat = data.frame(hla = c(df$hla, df$hla),
auc = c(df$depth_mcpas, df$glazer_server),
model = c(rep("DePTH McPAS (single)", 10), rep("CLAIRE", 10)))
df_reformat$model ... |
ee4004885661cb70d793f0492fe91903580481101e50ad35f38c4e0b660cde26 | R | 820 | 32 | #! /usr/local/bin/Rscript
## This is the automated script for greating the plots over the summary stats using SURVIVOR.
args<-commandArgs(TRUE)
if(length(args) != 1) {
cat("USAGE: produde_plots.R summary_file_chr\n")
}else{
if (!require("RColorBrewer")) {
#install.packages("RColorBrewer")
library(RColorB... |
a3e22dc72fed26eb26918621ec04dae2d435dd8238f922ceff285223d9025da8 | R | 822 | 18 |
#' @title Convert 6-state to 4-state GBM scores
#' @description 6 states: MES1, MES2, NPC1, NPC2, AC, OPC. 4 states: MES, NPC, AC, OPC. X1/2 are converted to X simply by taking the maximum score of the two columns.
#' @param scores dataframe of cell (rows) scores for the GBM meta-modules (columns).
#' @return the same... |
41719739174fa723fe9f38e76cdca31ddc0e827e8221f7a14c0e737d6750706f | R | 830 | 31 | # Merge all permutation files into one file
library(tidyverse)
library(glue)
path <- "bids/derivatives/meg-derivatives/grand_ave/brain-space/visual_model/permutations/{level}/"
path_save <- "bids/derivatives/meg-derivatives/grand_ave/brain-space/visual_model//permutations/{level}_perm_merged.csv"
for (level in c("V1"... |
ead79720f19594e4889188ff5b5b5659a85875ca24599f5acee1b378900fabc2 | R | 833 | 16 | gost_to_enrich <- function(gp) {
require(DOSE)
require(enrichplot)
# modify the g:Profiler data frame
gp_mod = gp$result[,c("query", "source", "term_id", "term_name", "p_value", "query_size", "intersection_size", "term_size", "effective_domain_size", "intersection")]
gp_mod$GeneRatio = paste0(gp_mod$intersection_s... |
1e89ce32acf3bba3a5814e9419962680ba744298febd2966b8b20d01465ed6eb | R | 840 | 18 | #' @title Convert logTPM to TPM
#' @description Convert logTPM to TPM, i.e. using 10*(2^(TPM)-1).
#' @param m matrix of logTPM values (gene rows; cell columns)
#' @param bulk if bulk then instead uses 2^(TPM)-1. i.e. no scaling. Default: F
#' @return TPM matrix
#' @details TPM/10 is used for single cells since 100,00... |
d3995576c5e3f6bee3037db91d1ca960f096c223ed818ed880c6959975a02ec5 | R | 843 | 21 |
#' @title Character List to Binary (membership) Matrix
#' @description Convert a list of character vectors to a matrix with i columns and j rows, where i are the list vector names and j are the unique elements found across i vectors. Cell i,j has a value of 1 if element j exists in vector i, and a value of 0 otherwis... |
23599d197136ee9ec97ec274b7dce75ae9fd6ea525743b7fe7ba61c461e89a74 | R | 853 | 38 | # shuffle input labels
#
# the script has two optional command line arguments:
# (1) a Boolean value that decides whether to preserve the class frequency
# (2) random seed for scrambling
library(tidyverse)
library(fs)
source("scripts/utils.R")
# process command line arguments
args <- commandArgs(TRUE)
if (length(arg... |
7976ad122d28f872498d2f684d4ce580763ff55d160a4c1a4097fe0040d54ce8 | R | 854 | 17 | ## Author: Youtao Lu <luyoutao@sas.upenn.edu>
## Copyright (c) 2017-2023, Youtao Lu and Junhyong Kim, Department of Biology, University of Pennsylvania
## Copyright (c) 2017-2023, James Eberwine, Perelman School of Medicine, University of Pennsylvania
## All Rights Reserved.
## This Source Code Form is subject to th... |
02cc485ad17cb522ff90147d0d963e0f4b7d0ad0d4805fd414eedd2bd67c8fe0 | R | 856 | 18 |
#' @title Aggregate `scalop::dea` output for one group against many in turn
#' @param L.dea list of gene-named-numeric log2-fold change values
#' @param coverage prioritise genes that appear as DE in at least this fraction of the dea result vectors in 'L.dea'. Default: 0.5
#' @param return.avg.lfc logical; if FALSE (d... |
9919d8c435d99efdb4fd7deeb4aff5bb1861f601f477d99779071ef6baca0aaf | R | 859 | 35 | # load data
MGH136 = readRDS('data/MGH136.rds')
# 1: Center expression matrix
MGH136.cent = scalop::rowcenter(MGH136)
# ... Using scalop::programs ...
# 2: Generate an ordered correlation matrix
# 3: Retrieve cell clusters with NO <K> CUTOFF. This is the real step 3!
# 4: Define gene programs from each cell cluster
#... |
f69b738cf3b0c5d7b0b5ab89a80d050c021e24303d6c272f6fb7aa2b3d5ac58c | R | 861 | 28 | library(tidyverse)
library(Seurat)
options(Seurat.object.assay.version = "v5")
options(future.globals.maxSize = 5e9)
library(SeuratObject)
library(Matrix)
Sys.setenv("_R_USE_PIPEBIND_" = TRUE)
library(future)
projdir <- here::here()
rdir <- file.path(projdir, "package/R")
import::from(.from = "cembav2env.R", .director... |
7a1312259c831fde5e2a99d6d1a0c8b3fe04c36d56e6e33f81c24246770b58ec | R | 869 | 24 | # R script to make MTSA input from Supplemental Data 2
# Dongwon Lee
d<-read.table('Supplemental_Data_2.txt', header=T)
thresh<-10^(-4)
d4<-d[d$gDNA_expr>thresh,]
tag_thresh<-4
goodprom<-names(which(table(d4$PROM)>=tag_thresh))
d4p<-d4[d4$PROM %in% goodprom,]
d4p<-d4p[order(d4p$PROM),]
d4p$log2expr<-log2(d4p$EXPR)
d4p... |
4a93ea578b037b70e3f679ea68b788b4d6761fc644f05e9e059f5a4b6ab876c4 | R | 872 | 36 | #!/usr/bin/env Rscript
library("argparse")
library("styler")
parser <- ArgumentParser(description = "Call styler")
parser$add_argument("dir",
metavar = "DIR", type = "character",
help = "File to parse"
)
parser$add_argument("--dry",
choices = c("off", "on"), default = "on"
)
args <- parser$parse_args()
f... |
8a410cd46512ba6ee025a84099c865ad0daa0463af9655810737729537539611 | R | 874 | 50 | #######################################
# LC snRNA-seq analyses: gene filtering
# Lukas Weber, Oct 2022
#######################################
library(here)
library(SingleCellExperiment)
# ---------------
# Load SCE object
# ---------------
# load SCE object from previous script
fn <- here("processed_data", "SCE... |
d0874c77a0783aaafa110a7f589a816aa4698a96669117f75480a7c7be0f419d | R | 878 | 25 |
library(here)
library(monocle3)
library(tidyverse)
source(here("scripts/accessory_functions/monocle_mods.R"))
source(here("scripts/accessory_functions/pattern_plotting.R"))
lmmp <- readRDS("/data/users/jared/ENS/6mo_LMMP/6month_LMMP.rds")
plot_cells(lmmp)
res <- top_markers(lmmp, group_cells_by = "clusters", genes... |
e1b08bc153a8434dc3bda7b6204c7a0d5e37f0a4d3d37c090a900c057cb1d30d | R | 884 | 14 | # SNPs for hg19 and hg38 are compiled from the publication:
#
# Westphal, M., Frankhouser, D., Sonzone, C. et al.
# SMaSH: Sample matching using SNPs in humans. BMC Genomics 20, 1001 (2019).
# https://doi.org/10.1186/s12864-019-6332-7
hg19_snps = data.table::fread(input = "https://raw.githubusercontent.com/rbundschuh/... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.