sha256 stringlengths 64 64 | language stringclasses 27
values | size int32 1 491k | lines int32 1 21.8k | content stringlengths 1 200k |
|---|---|---|---|---|
6f12d57f4091fbbc353415d09f8f8ec0b8699a3cb313ac38b2a2223c98720f23 | R | 1,081 | 29 | library(tidyverse)
library(fitdistrplus)
# Load data ---------------------------------------------------------------
data <- readRDS("data/cleaned/data_indiv.rds")
el <- readRDS("data/raw/edgelist_synthetic.rds")
spat_var <- readRDS("data/cleaned/data_venue.rds")
spat_var <- spat_var[order(spat_var$pop, decreasing=T)... |
1c0e3b621565bd157acffd482766f05e8ca138eebdfa55a37c0423ade144f00d | R | 1,082 | 35 | suppressMessages(suppressWarnings({
library(Seurat)
}))
source('Trinarization_score.R')
parser = argparse::ArgumentParser(description="")
parser$add_argument('-I','--input', help='input atlas')
parser$add_argument('-S','--species', help='input species name')
args = parser$parse_args()
obj <- readRDS(args$input)
... |
8bcfa5d3bdc2c19dd8737c03bd17ce0d260aeb22bebe331a9cc6af07da17e4cc | R | 1,084 | 29 | #!/usr/bin/env Rscript
# Round-trip finite numeric corpus values through base R binary64 parsing.
#
# Invocation:
# R --vanilla --slave --file=roundtrip_numeric.R --args INPUT.txt OUTPUT.bin
args <- commandArgs(trailingOnly = TRUE)
if (length(args) != 2L) {
stop("usage: roundtrip_numeric.R INPUT.txt OUTPUT.bin")
... |
b5a41d4bac8c91e71239ce339aff79b9fd4b8c6d90eb63f165aca5b38dcad8f2 | R | 1,085 | 28 | #' @title add_cell_annotation
#' @description Adds the data.frame with cell information to the loom file
#' @param loom loom file handler
#' @param cellAnnotation data.frame with the cell information
#' @return The .loom file
#' @export
add_cell_annotation <- function(loom, cellAnnotation)
{
cellAnnotation <- data.f... |
dfc52dea0cd225afb8451f7da9ad44ad92a49de6d5cb0fce31f34071636b06b7 | R | 1,087 | 33 | library(Seurat)
library(SeuratData)
library(cowplot)
library(dplyr)
#InstallData("cbmc")
cbmc <- LoadData(ds = "cbmc")
#preprocessing RNA assay
DefaultAssay(cbmc) <- 'RNA'
cbmc <- NormalizeData(cbmc) %>% FindVariableFeatures() %>% ScaleData() %>% RunPCA()
ElbowPlot(cbmc, ndims=50)
#preprocessing ADT ass... |
e0601eefa3aafd4c9a09340a2530453163a309dafa9ef419cc7c4422cae95643 | R | 1,087 | 43 | install.packages("BioManager")
BiocManager::install("SPOTlight")
BiocManager::install("SingleCellExperiment")
BiocManager::install("SpatialExperiment")
BiocManager::install("scater")
BiocManager::install("scran")
BiocManager::install("SpatialDecon")
if (!require("BiocManager", quietly = TRUE))
install.packages("Bioc... |
7b3079e493e597a7c889e20c34a4b48db27682b971d73864aac59e3b8c76d450 | R | 1,089 | 19 | # Load datasets one by one and process into a common format
# Files will be saved at: data/prelim_data
source("data_organization/1_load_all.R")
message('****************************************\n* Completed step 1 of 4\n****************************************')
# Process taxonomic data in a uniform manner
# Files wil... |
7cd292d67316a2c8a7e3ec58b3ddd1f9ed05799ae2dde2f55af3e5c9e692925a | R | 1,090 | 36 | ## Obtain the necessary data
if (!exists("modeling_results")) {
modeling_results <- fetch_data(type = "modeling_results")
}
if (!exists("sce_layer")) sce_layer <- fetch_data(type = "sce_layer")
## enrichment top 10 genes
enrich_top10 <- sig_genes_extract(
n = 10,
modeling_results = modeling_results,
mo... |
91fbe321e0fda15aa38ceab18d220f460e622fcf39987dec375684d68c0ced08 | R | 1,091 | 34 | ###################################################################################
#OR calculation function
oddsratioWald.proc <- function(n00, n01, n10, n11, alpha = 0.05){
#
# Compute the odds ratio between two binary variables:
#M2 <- matrix(c(1438, 1427, 18496, 18515), nrow = 2)
#rownames(M2) <- ... |
3f14ae6b4ebd5380cf2a093554ebaa9082003b3a8d8dd71e4b80549d5ba8a049 | R | 1,092 | 37 | countToTpm <- function(counts, effLen)
{
rate <- log(counts) - log(effLen)
denom <- log(sum(exp(rate)))
exp(rate - denom + log(1e6))
}
countToFpkm <- function(counts, effLen)
{
N <- sum(counts)
exp( log(counts) + log(1e9) - log(effLen) - log(N) )
}
fpkmToTpm <- function(fpkm)
{
exp(log(fpkm)... |
70f4750514660b19e164d9774d23f5eb03e82d3c15257a062d53353de3c55473 | R | 1,093 | 64 |
---
title: "Assess the relation between co-expression and PPI in scRNA-seq data"
author: "Wei Sun"
date: "`r Sys.Date()`"
output:
pdf_document: default
html_document: null
theme: journal
number_sections: yes
highlight: tango
smooth_scroll: no
editor_options:
chunk_output_type: console
toc: yes
toc_depth: 3
toc... |
d4fbcc2d5852a601b285a8f2be500c6e42ba5bf76282c8a6837286f51ad2f176 | R | 1,093 | 38 | # Copied from https://github.com/MRCIEU/TwoSampleMR/blob/master/R/mr.R#L256
# HASH 4f2902b
#' Perform 2 sample IV using Wald ratio.
#'
#' @param b_exp Vector of genetic effects on exposure.
#' @param b_out Vector of genetic effects on outcome.
#' @param se_exp Standard errors of genetic effects on exposure.
#' @param ... |
d989ec202ad3e52e1051db6002ef2ff6b2228321e60c44d1c01d05855cde0522 | R | 1,093 | 32 |
# Function to paste together columns, omitting NAs, and insert at a specified position
require(data.table)
# Function to paste together columns, omitting NAs, and insert at a specified position
paste_columns_dt <- function(dt, columns, separator = ",", new_col_name = "pasted_col", position = ncol(dt) + 1) {
# Cre... |
db274e689f31c9728e8fbe0ac53f2073a9f40cbfb9d68551cf489460bbb9f224 | R | 1,093 | 27 | # Import
csv_file <- "/data/project/1_Epilepsy_RNA/RNA_Animal/Raw_Data/Animal_sheet_FTP_3.csv"
file_data <- read.csv(csv_file, stringsAsFactors = FALSE)
file_data <- file_data %>% filter(Species == "R")
files_and_labels <- setNames(file_data$Filepath, file_data$Group)
# Initialize an empty list to store dataframes
li... |
f7db6b9bc72a464353b408a788ea99c8b9c52dc58b533cb0b1f86859418bee78 | R | 1,093 | 27 | # Import
csv_file <- "/data/project/1_Epilepsy_RNA/RNA_Animal/Raw_Data/Animal_sheet_FTP_3.csv"
file_data <- read.csv(csv_file, stringsAsFactors = FALSE)
file_data <- file_data %>% filter(Species == "M")
files_and_labels <- setNames(file_data$Filepath, file_data$Group)
# Initialize an empty list to store dataframes
li... |
030abfbf881fd36a12e4404b9cd0fc018432513ccd8d206bcbaa26add218fcb7 | R | 1,102 | 32 | source(".utils.R")
# Bundle up the package into a .tar.gz file.
package_path <- devtools::build(".", path = ".")
# Hack to get around this issue:
# https://stat.ethz.ch/pipermail/r-package-devel/2020q3/005930.html
#
# The system clock check during `R CMD check` relies on two external web APIs and fails
# when they ar... |
38e3abddbbcadf4276a7ba220ac0cd2539fe142bc6213eafcd3182ba8afafafa | R | 1,103 | 26 | library(ggplot2)
library(viridis) # Load the viridis package for the color palette
# Load your data
dataeli1 <- read.csv("copieddata.CSV", sep = ";", dec = ",")
# Create the line graph for AvgFitness over Generation
ggplot(dataeli1, aes(x = Generation, y = AvgFitness)) +
geom_line(size = 1, color = viridis(1, opti... |
70aca2fc6e0a5bb8ac9e5f913e6c59a5eed252cfbc27861ac49cfe65c188a717 | R | 1,108 | 31 | .onAttach = function(libname = find.package("LESYMAP"),
pkgname = "LESYMAP")
{
# set URL
description = 'https://raw.githubusercontent.com/dorianps/LESYMAP/master/DESCRIPTION'
# Try to establish a connection
suppressWarnings( conn <- try( url(description) , silent=TRUE ) )
# If connecti... |
52d936664c20350eae1fd7f66ba58eccb0a0f92447625440fb256f5c14430669 | R | 1,110 | 44 | #' @title Display info messages in console
#'
#' @description
#' Displays in the R console the information sent
#' by LESYMAP functions.
#'
#' @param message character binary matrix (0/1) of voxels (columns)
#' and subjects (rows).
#' @param type decides how to add newlines and timestamp by choosing
#' between the ty... |
6dbf34ffa48a30abed9371bd70cd42979d03b54f26b114d18e0bb0a36487176b | R | 1,112 | 38 | library(DESeq2)
library(ggplot2)
library(pasilla)
### Choose one matrix to analyze ###
### raw data
dds_data <- Expr_matrix_1
dds_coldata <- coldata_df_1
Target_comparison <- 'FILTERED_1_MTLEALL_NL'
contrast_vector <- c("Diagnosis","MTLEALL","NL")
## dds
dds_data <- round(dds_data)
dds <- DESeqDataSetFromMatrix(coun... |
d6f668515cbc25510aa7df5701a9139a69b734304b80f2533d744ffd5d768c05 | R | 1,112 | 42 | dat <- read.table("C:/research/paper/review/memory and time/a10000memory_A.csv",
sep = "|", header = TRUE, stringsAsFactors = FALSE)
dat$MaxRSS_MB <- as.numeric(sub("M$", "", dat$MaxRSS))
dat$AveRSS_MB <- as.numeric(sub("M$", "", dat$AveRSS))
summary_mem <- data.frame(
n_rep = su... |
570126b4fcf29cc7dc2d4c744668f23bf2c97ada1828005b7f78e9a071ce87b0 | R | 1,116 | 30 |
### Append concentration to each internal standards
## Mboat2 OE and lipid supplementation
rm(list=ls())
library(tidyverse)
setwd(rstudioapi::getActiveProject())
load("./Output_Data/M2OE.MS-Dial_IS.all.Rdata")
load("./Input_Data/IS_new_conc_July_batch1_2.Rdata")
Class <- as_tibble(c("PC", "LPC", "PE", "LPE", "PG", "... |
3742b791bd67818e7a31eb3b89005df1ce345621559023924f98e795c22eced0 | R | 1,117 | 33 | library(ggplot2)
library(dplyr)
library(viridis)
# Your data
data <- data.frame(
Model = c("Lagrangian Particle Tracking Models", "Individual-Based Models",
"Genetic Models", "(Math.) Behavioral Models",
"Metapopulation Models", "Process-Based Models"),
Count = c(29, 13, 2, 1, 1, 1)
)
# ... |
0d176eeab6e50c8547474258eeb122f21fafb1c44c0bba6e41246ea1ef31f906 | R | 1,119 | 34 | #' Setup R Environment for Lattice Kriging Analysis
#'
#' Activates renv and loads required libraries. If renv.lock is missing, sources setup.R to create the environment.
#'
#'
activate_environment <- function(module_dir, requirements_file) {
# Stop if no requirements file is provided
if (missing(requirements_f... |
dff3c57f5b2431d3ebd5c59e8f3bccc059856ee71723a1cf58e1f2d19c315400 | R | 1,122 | 28 | library(Seurat)
library(ggplot2)
library(dplyr)
library(cowplot)
library(reshape2)
library(MIN)
library(EnhancedVolcano)
DV <- readRDS("DVPV_integrated_PCA_0.1_both.rds")
DefaultAssay(DV) <- 'integrated'
DV <- ScaleData(DV, verbose = FALSE)
DV <- RunPCA(DV, features = VariableFeatures(object = DV), verbose = FALSE)
El... |
c75169d2304530c583567d09caf0a635711f656bb7f07000f796ec4d54e66ec4 | R | 1,126 | 24 | test_that("multiplication works", {
skip_if_not_installed('reticulate')
token=try(chunkedgraph_token(), silent = TRUE)
skip_if(inherits(token, "try-error"),
"Skipping live flywire L2 tests")
skip_if_not(reticulate::py_module_available("fafbseg"),
"Skipping live flywire L2 tests requiring... |
2d8264b29c28de6d9ed6aa6db5e842618d117c2d4cd9f3bccb8ea1f7e5793471 | R | 1,134 | 29 | #example code. core codes for every violin plots in the paper is same.
df.summary <- df %>%
group_by(condition) %>%
summarise(
sd = sd(Sox2, na.rm = TRUE),
Sox2 = mean(Sox2)
)
df.summary
library(ggplot2)
library(ggpubr)
library(RColorBrewer)
p <- ggplot(df, aes(condition, Sox2, fi... |
92d51af8b8e7bebea74010770f2af14c4927ecadb462c56c49db96b2867ebe21 | R | 1,135 | 39 | PL2_MVMR_TWO = function(ab){
b=ab
w=NULL
cov = matrix(nrow = exp.number, ncol = exp.number)
for(l in 1:nrow(r_input)){
for(pp in 1:exp.number){
for(p2 in 1:exp.number){
cov[pp,p2] <- correlation[pp,p2]*stderr[l,pp]*stderr[l,p2]
}
}
w[... |
9a7778cf0ce7eae3e0d7b521b6bb958fc4d8c523f62b92215035d29e5ed147d5 | R | 1,136 | 49 | # if(!require(devtools))
# install.packages(devtools)
# devtools::install_github("zhengli09/BASS")
library(BASS)
library(scater)
library(anndata)
set.seed(101)
for (i in c(151507:151510,151669:151676)){
if (i %in% c(151507:151510,151673:151676)){
R <- 7
} else {
R <- 5
}
i <- as.character(i)
ST <... |
f10f19063193ba7f9ff909cbda9591aab15eb4ad2150ee6aa0c33390fba3aea2 | R | 1,137 | 47 | #!/usr/bin/Rscript
args <- commandArgs()
#print(args)
dir <- args[6]
Name <- args[7]
# read csv
Counts <- read.csv(paste(dir, Name, sep="/"), header=F, sep = "")
colnames(Counts) <- c("Freq","Barcode")
#head(Table)
#split barcode name
Counts$P5 <- substr(Counts$Barcode,22,26)
#head(Counts)
P5s <- sort(unique(Counts... |
a6d59be8ddc74cb864248e76cbcead467520fc831c2a8e1c56e79474eb07d7b7 | R | 1,140 | 46 | # Tests for ArchR
# change in random number generation in R3.6, this ensures tests will pass under older and newer Rs
# (this was implemented in Seurat's testthat)
library(ArchR)
library(testthat)
library(Matrix)
suppressWarnings(RNGversion(vstr = "3.5.3"))
set.seed(1)
clear_test_dir <- function(){
files <- list.fil... |
974599144fecbfdbb3ebddf72f42ad96f3c56a8b33b3c6f8dde37ba5807e3f8d | R | 1,142 | 26 | ### Side chain analysis - summarize the total concentration of lipids of each class that contain the identical side chains
### For SM and Cer, sphingoid base and FA is calculated separately
### For ether lipid, ether-linked side chain is calculated separately from ester-linked side chain
rm(list = ls())
library(tidyve... |
d0500d457de77cdbca6181fa7cb1c1f47dec3e86cb25bce20c22a9f65901b291 | R | 1,142 | 45 | #' @title Regression tests for symptom mapping (slow)
#'
#' @description
#' Lesion to symptom mapping performed on a prepared matrix.
#' Regressions are performed between behavior and each column in the
#' lesmat matrix.
#'
#' @param lesmat matrix of voxels (columns) and subjects (raws).
#' @param behavior vector of be... |
833eff7fc709877a8b1d8370693b3373ad0b1b41c09859690f6000cd79979edf | R | 1,143 | 17 | library(ggplot2)
## ---- load individual trials ---- ##
setwd("") # set current working directory
df <- read.csv('./ft_fig_data.csv',sep = ",",stringsAsFactors = FALSE)
df$trialtype[df$trialtype==1] = 'Illusion'
df$trialtype[df$trialtype==2] = 'Replay'
## Supplementary figure: density plots by trial type
dp ... |
556c90c02b210e0deda119ed680d32494b7340b16c3102139d1d8844ad37b842 | R | 1,145 | 45 | library(CARD)
library(scater)
library(anndata)
st_path <- "./simulated_gene_expression_average.h5ad"
ST <- read_h5ad(st_path)
SC <- read_h5ad("SC.h5ad")
sc_adata<- t(SC$X)
st_adata <- t(ST$X)
st_adata <- round(st_adata)
cell_type <- SC$obs$cell_type
cell_type <- factor(cell_type)
cellID <- factor(colnames(sc_adata)... |
890746a9cbc29cf4fd4a6cc39f68d68ee74620603de1f70fd30f110d689ca3ee | R | 1,146 | 45 | # single-cell analysis package
library(Seurat)
# plotting and data science packages
library(tidyverse)
library(cowplot)
library(patchwork)
# co-expression network analysis packages:
library(WGCNA)
library(hdWGCNA)
# gene enrichment packages
library(enrichR)
library(GeneOverlap)
# using the cowplot theme for ggplot
... |
724baff4201fd3187f07f67f72e8d749239624e6dc1ce6be1d439cd238442413 | R | 1,151 | 24 | #count gene exon length
#for isoform, use the right reference file.
library(GenomicFeatures)
txdb <- makeTxDbFromGFF("gencode.v42.chr_patch_hapl_scaff.basic.annotation.gtf",format="gtf")
exons_gene <- exonsBy(txdb, by ="gene")
exons_gene_lens <- lapply(exons_gene,function(x){sum(width(reduce(x)))})
exons_gene_lens1 ... |
fcacc93902e0066d9911dbae5657950fd932ac98d1429ad041c054f3b7833537 | R | 1,153 | 36 | # ===============================================================
# 🧬 Linear Mixed Model (LMM) — single random intercept
# ===============================================================
lmm_ui <- function(id) regression_ui(id, "lmm", allow_multi_response = TRUE)
lmm_server <- function(id, data) regression_server(id... |
35b135659a35ed6d6628bab8130e858542961cae7da2ad268d14ea131152ecbe | R | 1,156 | 39 | # This script calculates nucleotide diversity (pi) for each transcript in the dataset.
# It takes the alignment files (output of script 08) and calculates pi using the pegas package.
# Load libraries
library("ape") # version 5.8
library("pegas") # version 1.3
# Paths
path_alignments <- "Data/08.Alignments/out/"
path_... |
dfcad191fe7ed314c97143ac522b8bc4b2950e227055a673d3e836ab9310baa0 | R | 1,156 | 36 | # Script to determine the overlap between a set of metaprograms and previously published genesets/metaprograms
metaprograms_enrichment <- function(mp_list, pathways = NULL, min_gs_size = 40, max_gs_size = 500) {
if(is.null(pathways)) {
stop("Error: Pathway list or dataframe must be provided.")
}
... |
b6e2c7922749a66da775fbb395089fe611759d1ee616ead4748708a8ada5603b | R | 1,160 | 39 | context("Model")
library("keras")
library("reticulate")
testthat_model_dir <- tempfile("model_")
setup({
use_python(Sys.getenv("RETICULATE_PYTHON_BIN", "python"))
})
teardown({
mlflow_clear_test_dir(testthat_model_dir)
})
test_that("mlflow can save keras model ", {
PATH <- Sys.getenv("PATH", "") # keras pa... |
db6a40c05a7672e8e16b4b4e36f2dd81f80c72f4c885b75428eeff2ac72ebaaa | R | 1,161 | 32 | # Configuration file for coTWAS analysis
# Paths and parameters
# Input paths
METADATA_PATH <- "./coTWAS/metadata.RData"
COMMON_GENES_PATH <- "./coTWAS/Common.Genes.Models_updated120924.RData"
UNIQUE_GENES_PATH <- "./coTWAS/Unique.Genes.Models_updated120924.RData"
GENE_INFO_PATH <- "./gene_annot.rds"
# Predi... |
74cc89d3e57d26ed985e943236127417c79df93fdd993370c0c63e77297654c0 | R | 1,162 | 32 | ## export gene table to db
library(tidyverse)
library(DBI)
con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB")
setwd("/Volumes/Helix-Common/GLASS-analysis/")
generef = read.delim(file = "data/ref/ncbiRefSeqCurated_hg19.tsv", as.is = TRUE)
genecov = read_tsv(file = "data/ref/gene.covariates.txt")
df = generef %>%
g... |
c54294d880f297c305b866bb82b55f7e59933bd92376f8c6f22c770c9e54bfc0 | R | 1,171 | 36 | #!/usr/bin/env Rscript
# -*-coding: utf-8 -*-
#-----------------------------------------------
# Title: Custom Theme adapted from theme_bw()
# Author: Amanda Zacharias
# Date: 2025-06-06
# Email: 16amz1@queensu.ca
#-----------------------------------------------
# Notes -----------------------------------------------
#... |
d85e0d0f1023771a13fce7b9ec0e9ed11906d5729ae742b75991e25a538a7fed | R | 1,172 | 36 | #This file contains details on how to cache http requests before using them in mock apis for offline testing
library(httptest)
library(fafbseg)
#Step 1: Set the folder locations..
testpath = paste0('./',test_path())
.mockPaths(testpath)
#Step 2: Start capturing http data from now..
start_capturing()
#Now add test... |
6b04f4f0739d2eb41ef74ccf6d7798c62d70d28b2c141305b0bbd0e0e86a1a50 | R | 1,173 | 32 | ## ----setup, include=FALSE----------------------------------------------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)
# setwd("/Users/warri/OneDrive/Documents/Denver/Research/Data/ashad_n110")
sessionInfo()
# RDAC R packages location '/home/rcorcoran/R/x86_64-pc-linux-gnu-librar... |
b643099af35967a34a88f0aa2794d9e3a64a1ef2379df1aa57680507a50d43b0 | R | 1,173 | 43 | #!/usr/bin/env Rscript
#-------------------------------------------------
# Title:
# Author: Amanda Zacharias
# Date: 2023-07-17
# Email: 16amz1@queensu.ca
#-------------------------------------------------
# Notes -------------------------------------------
# module load nixpkgs/16.09 gcc/7.3.0 r/3.6.0
#
#
#
# Options... |
b634be06a0ddc65c1cbfac710b1e752eaeaba514e4d01d7e0eedff1dee52ca3f | R | 1,174 | 35 | test_that("manc_scene works", {
withr::local_options(choose_malevnc_dataset('VNC', set = F))
expect_is(manc_scene(), 'character')
# check we can set ids for all scenes
basescenes=eval(formals(manc_scene)$basescene)
for(bs in basescenes) {
# very first scene doesn't accept dvid nodes
message(bs)
i... |
c722c530d2b49cf97b336710ab6a632f4bd464cae2bd56afd4c314685072b53e | R | 1,183 | 28 | context("test-brainmaps-api")
test_that("parse brainmaps uri works", {
expect_error(parse_brainmaps_uri("wurgle"))
expect_error(parse_brainmaps_uri("brainmaps://"))
uri = "brainmaps://772153499790:fafb_v14:fafb_v14_16nm_v00c_split3xfill2_flatreseg2_skeletons32/teasar512_nnconn165_mc10000_prune10_thresh1000_spa... |
21c3a82897e14126d208d7435dc3a1e0c3d1ee36ce12db44f4597c3fba29156e | R | 1,188 | 42 | #!/usr/bin/env Rscript
#-------------------------------------------------
# Title: Get results from DEA
# Author: Amanda Zacharias
# Date: 2023-07-17
# Email: 16amz1@queensu.ca
#-------------------------------------------------
# Notes ------------------------------------------
# module load nixpkgs/16.09 gcc/7.3.0 r/3... |
8e3245dabf8dd1991d9983817fc4daa0b11ba49c34c6242981a0eb9d7b54b7a6 | R | 1,191 | 41 | library(dplyr)
library(readr)
library(UpSetR)
library(GSEAB)
# Define the folder path where _down_to_up.csv files are stored
#input folder_path
# List all _down_to_up.csv files in the directory
csv_files <- list.files(path = folder_path, pattern = "\\.csv$", full.names = TRUE)
# Initialize an empty list to store en... |
1c3c97e5f2b09fa7a9c9e7a4f9eb21460639f17519801815ef992e9aebf112ba | R | 1,195 | 29 | #' @name mn_data
#' @title mn_data
#'
#' @description A SummarizedExperiment object containing: a gene matrix,
#' cell type labels, experiment labels, sets of genes, sample ID, study id and
#' cell types.
#'
#' @docType data
#'
#' @format
#' \describe{
#' \item{Gene matrix}{A gene-by-sample expression matr... |
7e3bb31bad12e6b5a41af48845265bc8498be9c20bbcc21cbd6cab0f56825c4e | R | 1,196 | 27 | ### Append concentration to each internal standards
rm(list=ls())
library(tidyverse)
setwd(rstudioapi::getActiveProject())
##IS from previous analysis
load("./Output_Data/GPMV.MS-Dial_IS.all.Rdata")
IS.GPMV.all <- IS.GPMV %>%
rowwise() %>%
mutate(Class = str_split(Metabolite.name, " ")[[1]][1]) %>%
relocate(C... |
7e9638a41abd3907ea204e278cf86408603119233edfc09a893fbb24e1c52d71 | R | 1,198 | 38 | ### Effect size between control and GPMV-supplemented samples
#(pos ES -> higher in Treatment)
#(neg ES -> higher in Control)
rm(list=ls())
library(tidyverse)
source("./Scripts/Function_scripts/Effect_size_functions.R")
# === Effect size calculation on individual lipids====
load(file = "./Output_data/PM_supp_LIPID.Rda... |
186690209132042ea5a8cbae0396a22dc9e2b91300baefab1228295dc6778ee5 | R | 1,199 | 32 | test_that("secrets work", {
skip_if_not_installed('mockery')
skip("Skipping due to mockery stub issues")
# see https://github.com/r-lib/mockery/issues/30
td=tempfile()
on.exit(unlink(td, recursive = T))
mockery::stub(flywire_set_token, "cv_secretdir", td, depth = 3)
mockery::stub(chunkedgraph_token, "cv_s... |
659d1edef601548daafa03b6cd430c34b83a550da100c4f13984c66dc1c2fb5e | R | 1,199 | 44 | library(tidyverse)
library(data.table)
library(future.apply)
plan(multicore)
setwd("futcounts")
files = list.files(pattern = 'Primary_Gene_Assigned_exon.txt')
samples <- gsub("Primary_Gene_Assigned_exon.txt", "", files )
myfiles = lapply(files, read.table,sep="\t",fill=TRUE,header=T)
tmp <- Reduce(dplyr::full_join, ... |
1882775138b7ec40a4f8dc822c07f67fbcc172aae5af3fc2e34b9f1f3fd3a248 | R | 1,201 | 49 | context("test PUMA")
test_that("puma() runs and returns panda object", {
skip_on_cran()
# Create minimal test data
set.seed(42)
tfs <- paste0("TF", 1:3)
genes <- paste0("G", 1:5)
mirs <- paste0("TF", 1:3)
motif <- data.frame(
tf = rep(tfs, each = 5),
gene = rep(genes, 3),
score = rbinom(15,... |
cf9bee23476651627bace6b7c2fb54c4b72b39e65b84dc1a951e3ea8ef259a79 | R | 1,204 | 43 | library(tidyverse)
library(data.table)
library(future.apply)
plan(multicore)
setwd("futcounts")
files = list.files(pattern = 'Primary_Gene_Assigned_exon.txt')
samples <- gsub("Primary_Gene_Assigned_exon.txt", "", files )
myfiles = lapply(files, read.table,sep="\t",fill=TRUE,header=T)
tmp <- Reduce(dplyr::full_join, ... |
6ce871c3454a0d1b7bab1669c1e61ed8a350c0a6f9513bb1f36499e6afcdc245 | R | 1,206 | 44 |
# Load gene-level association results
load("PGC3_snellius/coTWAS/result/output_all.RData")
result$tissue.gene = paste0(result$gene,".",result$tissue)
result$chr = gsub("chr","",as.character(result$seqnames))
result.noMHC = result[result$MHC %in% "noMHC",]
# Ensure correct ordering
genes <- result.noMHC[order(result.n... |
824ed090f98b6f2ada3b11003ef02f5c6a0d97ae3d06d2aff1e482166d10876a | R | 1,206 | 36 | install.packages("remotes")
install.packages("tidyverse")
install.packages("grid")
install.packages("gplots")
install.packages("gridExtra")
install.packages("pheatmap")
install.packages("matrixStats")
install.packages("doMC")
install.packages("umap")
install.packages("Matrix")
install.packages("princurve")
i... |
55c81e6e2beb673f3703bcd391fd56e834ccd3966a8e245676af5e924d649e8f | R | 1,207 | 35 | #!/usr/bin/env Rscript
#######################################################
library(tidyverse)
library(odbc)
library(DBI)
#######################################################
#Establish connection
con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB4")
args = commandArgs(trailingOnly=TRUE)
# test if there is at l... |
f7e51e7e61f1c130d7b84cef4973e3aa7db275ab8cca0f007f449620988ed06b | R | 1,212 | 47 | unit.test <- function(test,pass,fail){
# test: logical expression to evaluate
# pass: error to print if true
# fail: error to print if false
if(test){
print(pass)
} else{print(fail)}
}
fisher.r.to.z <- function(r){
r <- 0.5*(log(1+r) - log(1-r))
return(r)
}
colSD <- function(x){
return(apply(x,2,sd))
}
... |
cdabf8285fe5422431746456bbc45f7161e3e03a313068a18335f0a010afca00 | R | 1,220 | 30 | test_that(
"multi_gene_pca",
{
# With two good columns but 1 zero-variance column, the zero-variance
# column should be dropped with a warning
cont_mat <- matrix(c(1, 0, 3, 3, 2, -5), ncol = 3)
colnames(cont_mat) <- c("good1", "bad", "good2")
expect_warning(
... |
77367962278841390fe3f8df6df7cd8d881304c5cf47cbdbc75e20b57ae3fe17 | R | 1,221 | 48 | #!/usr/bin/Rscript
### This function returns the LD matrix computed from the compressed binary file
### output from REGENIE
### ld.file: binary file output from Regenie
get.corr.sq.matrix <- function( ld.file = NULL ){
if(is.null(ld.file) || !file.exists(ld.file))
stop("Need to pass valid LD file!")
list.... |
02b3467f02158a88b3ae72794fea200b7e17e4ccaa0340e7f26baaedb5b2da71 | R | 1,222 | 46 |
### use ov.from.bam3 function to import a bamfile into a data.table
dt.from.bam <- function(bamfile, pattern='.bam', bamname=NULL, ...) {
message('Start analyzing ', bamfile, '...')
bam <- data.table(NULL)
## Sample name
if (is.null(bamname)) {
bamname <- gsub('.*\\/', '', bamfile)
bamname <- gsub(... |
98185f248da02d1317aaf0de4c99017e844bbb9c7f906c504bd5a8b69a82cfa0 | R | 1,223 | 47 |
## following the walkthrough tutorial, walkthrough.md
library(conos)
library(pagoda2)
con <- Conos$new(small_panel.preprocessed, n.cores=1)
test_that("check Conos object, samples", {
expect_equal(length(con$samples), 2)
})
test_that("check getDatasetPerCell()", {
expect_equal(length(con$getDatasetPerCell()), 59... |
b6097bd8999091b4f2b1860679e7690271b1c8ce664e5234be5480c4bbc5a443 | R | 1,223 | 55 | library(readr)
library(readxl)
library(ggplot2)
user_colors <- c(
"1"="green",
"2"="red",
"3"="blue",
"4"="gold",
"5"="darkcyan",
"6"="brown3",
"7"="royalblue2",
"8"="cyan",
"9"="lightgreen",
"10"="yellow3",
"11"="purple",
"12"="powderblue",
"13"="azure3",
"14"="royalblue1",
"15"="cyan3",
... |
2336566742b6efc51251950f28af33674e69168d39a2fc79ef5fe01cfb029893 | R | 1,225 | 44 | #' Source a Script with MLflow Params
#'
#' This function should not be used interactively. It is designed to be called via `Rscript` from
#' the terminal or through the MLflow CLI.
#'
#' @param uri Path to an R script, can be a quoted or unquoted string.
#' @keywords internal
#' @export
mlflow_source <- function(uri... |
467eea74c7ab164687511d179543a676b9c144772293e0b135049fb433ced531 | R | 1,227 | 36 | # Moderate effect size genes project
# Author: Madison Caballero
# Desription: Calculates probability of co-occurance
args = commandArgs(trailingOnly=TRUE)
gene = args[1]
# Calculated from the SPARK parents. Gene and frequency of ultra-rare deleterious variant.
STAT <- read.delim(file = "parental_gene_mut_stats.txt",... |
5ae442b3043e94d367b3c82d14649a5203424c4f4a1d144f97e8206aef37a59a | R | 1,227 | 33 | ### Extract internal standards from all samples of GPMV lipidomics
setwd(rstudioapi::getActiveProject())
rm(list=ls())
library(tidyverse)
library(stringi)
library(matrixStats)
##Input IS concentration
load("./Output_Data/IS_Ion_for_quantification.Rdata")
## ==== GPMV ====
## ==== GPMV ====
GPMV.label <- read.csv("... |
9ca57d2596b71c29d6db61ed99cee1c1582839bc58bf835b9a4339e5e3110992 | R | 1,228 | 36 | #' @title Regression tests for symptom mapping (permutation p-vlaues)
#'
#' @description
#' Lesion to symptom mapping performed on a prepared matrix.
#' Regressions are performed between behavior and each column in the
#' lesmat matrix. This function relies on the lmPerm package
#' to run. The number of permutations re... |
5a9cd770cfaed11c76904f54f705eed022dfc55fe5728e8130b68e8aee46c99f | R | 1,229 | 29 | ### Side chain analysis - summarize the total concentration of lipids of each class that contain the identical side chains
### For SM and Cer, sphingoid base and FA is calculated separately
### For ether lipid, ether-linked side chain is calculated separately from ester-linked side chain
rm(list = ls())
library(tidyve... |
81a1cdf8953ebcc880f5b4f8ad5896ff5a5a8f9923026ee8c0004829aa48cb23 | R | 1,231 | 29 | ### Side chain composition analysis
setwd(rstudioapi::getActiveProject())
rm(list = ls())
library(tidyverse)
source("./Scripts/Function_scripts/Pre-processing_functions.R")
load("./Output_Data/Invivo.MsD.29.lipid.raw.conc.Rdata")
## ==== Aggregate lipids with the same number of double bonds for each class, in each ... |
3b7a78599edf6ad9c0a052126c101f4ed5d349197fa2b6a4934a900981883a51 | R | 1,238 | 54 |
library(SingleCellExperiment)
library(ggplot2)
library(BayesSpace)
library(anndata)
library(scran)
options(matrixStats.useNames.NA ="deprecated" )
set.seed(101)
start <- Sys.time()
dlpfc <- read_h5ad("./simulated_gene_expression_average.h5ad")
counts <- t(dlpfc$X)
counts <- round(counts)
index <- colSums(counts)>0... |
fa6cb97fecbcd7dca7cd1a3d3914ca5475f7db30b61a737080cfcf4a1204e385 | R | 1,238 | 40 | ---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# SpNeigh
SpNeigh provides methods for neighborhood-aware ... |
6aebb27ee055fa95fb2d15e9540af2d36481373f4baff9be1449a6875ac09c75 | R | 1,241 | 35 | library(corrplot)
library(RColorBrewer)
# regions of interest
regs = c('CB', 'HPF', 'STRd', 'OLF', 'Isocortex', 'BS', 'MB', 'TH', 'PAL', 'HY')
my_palette <- rev(colorRampPalette(brewer.pal(9, "RdYlBu"))(100))
# function to get change in prop for heatmap
get_change_in_prop <- function(df, regs){
mat1 = df[match(r... |
adcc24429219360b1be95fcffaa5b46d233dce5266ad10c4754dcffdcb5da88f | R | 1,245 | 33 | #################################
# Push sequenza seg into db
# Updated: 2022.03.01
# Author: Kevin Johnson
#################################
library(tidyverse)
library(DBI)
library(odbc)
con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB4")
seg <- read.delim("results/sequenza/glass_seqz_segments.tsv", as.is = TRUE)
pp <-... |
162fb60c0db940cac2e23518fe3f1c8a37b2497f0f88f1948f9e46254f981876 | R | 1,247 | 34 | library("NbClust")
library(proxy)
Indices <- c("kl", "ch", "hartigan", "ccc", "scott", "marriot", "trcovw", "tracew", "friedman", "rubin", "cindex",
"db", "silhouette", "duda", "pseudot2", "beale", "ratkowsky", "ball", "ptbiserial", "gap", "frey",
"mcclain", "gamma", "gplus", "tau", "dunn",... |
6485c48f0a1217eebd5b7d848ef559569e04f5aab1ef031906315e84fbf1c370 | R | 1,248 | 44 | #!/bin/Rscript
args = commandArgs(trailingOnly=TRUE)
if (length(args)==0) {
stop("At least one argument must be supplied")
} else {
data_path = args[1]
}
library(randomForest)
library(jsonlite)
library(sesame)
library(plotly)
library(arrow)
message("Running: ", data_path)
message("Loading idats from: ", file.pa... |
29239ec1d7073a58bbc10cc022b3e06e46225e593bf6df1dec6b32bc5cff541b | R | 1,253 | 38 | ##################################
# Add metadata for infercnv results for CARE astrocytoma cohort.
# Author: Kevin Johnson
# Date Updated: 2026.03.18
##################################
## Run in infercnv_env conda environment
## Extract infercnv metadata to identify malignant cells.
library(tidyverse)
library(inferc... |
702be0abba150070225bec17b8c1aab89cca0bbdc4860073f488c5a7736f43c0 | R | 1,255 | 29 | # Function to compute summary statistics (min, quartiles, median, max) for a numeric dataset
summary_stats <- function(data, row_name) {
# Convert input data to numeric format (if not already)
data <- as.numeric(data)
# Check if all values are NA; return empty statistics if true
if (all(is.na(data))) {
w... |
e2ef95aee99813e0c08bf549080db09c6fb38ccd2469fa3b024315b6f08c7e8f | R | 1,259 | 26 | #' @title Console print of lesymap object
#'
#' @description
#' Funciton to display some meaningful summary
#' when a lesymap output is called in command line.
#'
#' @param x the output from a lesymap() call.
#' @param ... useless for compatibility with default print.
#'
#' @author Dorian Pustina
#'
#' @export
print.le... |
7f9cc5f3b34f83ed174a23cd825c7ebc4b137b95907922dcc2256a8acc364159 | R | 1,261 | 36 | library(ggplot2)
library(dplyr)
library(tidyr)
# Your data in a data frame
data_comparison <- data.frame(
Dimension = c("3D", "2D", "1D"),
Percentage = c(71.4, 28.6, 0),
Count = c(77.9, 20.8, 2.6)
)
# Reshape data into long format to make it easier to plot side-by-side
data_long <- data_comparison %>%
pivot_l... |
b89e0fd3efdb4a841629e55bd52e62627fbbbfc8c4908b91b9a6152fc20d48b1 | R | 1,262 | 47 |
```{r}
library(dplyr)
library(tidyr)
library(tibble)
# --- Pearson-only correlation helper (returns n, r, p) ---
safe_cor_stats <- function(x, y) {
ok <- stats::complete.cases(x, y)
n <- sum(ok)
if (n < 3) {
return(tibble(n = n, r = NA_real_, p = NA_real_))
}
ct <- suppressWarnings(stats::cor.test(x[... |
0758e5d0c4f5829adf221cfc68e07f8ce1938b181beb3de17f9ddc8d3d2dcac3 | R | 1,263 | 32 | library(dplyr)
## Merge MIND matrix into one file
setwd('/home/huyang/Projects/HuYang/HY_20250708')
## Load sublist
sublist <- scan('./PROCDATA/LIST/t1_sublist_postqc.txt', what = '')
## Merge MIND
atlas_names <- c('Schaefer.300Parcels.7Networks', '500.aparc')
meas_names <- c('FF', 'CT', 'CV')
for (curr_atlas in atlas_... |
b20814276f6bb3273a059965d983fbdce318b0a63e33599cef1ceefd88764393 | R | 1,263 | 37 | ########################## Step.01 Load data ##########################
# Load all CellRanger result
if(T){
files = dir('data/scRNA/',pattern = '_cellranger')
for(file in files){
file.path = paste('data/scRNA',file,'filtered_feature_bc_matrix',sep = '/')
print(file.path)
temp = CreateSeuratObject(Read1... |
1dc716cef9856ec9ef4e50b6e40c0fbab736debe78fad130f857cb40d299041f | R | 1,265 | 50 | #!/usr/bin/env Rscript
#######################################################
library(odbc)
library(DBI)
#######################################################
rm(list=ls())
#Establish connection
con <- DBI::dbConnect(odbc::odbc(), "VerhaakDB4")
args = commandArgs(trailingOnly=TRUE)
# test if there is at least o... |
38b517ce51963d2c0587c003551afb7056264b36669313d177883f2f5d135a56 | R | 1,265 | 38 | ##################################
# Add metadata for infercnv results for CARE oligodendroglioma cohort.
# Author: Kevin Johnson
# Date Updated: 2026.03.18
##################################
## Run in infercnv_env conda environment
## Extract infercnv metadata to identify malignant cells.
library(tidyverse)
library(... |
dddac887712d6cea98267fb7c0addca76dbf67351776c23199e39547c7ca42b3 | R | 1,268 | 43 | #' Update the images for all samples
#'
#' This function uses `img_update()` for all samples. That is, it loops through
#' every sample and edits the image with `img_edit()` and then updates the
#' `imgData()`.
#'
#' @inheritParams img_update
#'
#' @return A
#' [SpatialExperiment-class][SpatialExperiment::SpatialExperi... |
0638945cf757ff1148ab84a2bebd0d618bb2629bf285eaac5642faaef35ca3c7 | R | 1,273 | 40 | # -----
# UMS IPSIT BIOINFO - Licence GPL-3
# https://github.com/fdumbioinfo/moal
# -----
#
# moal install
source("https://raw.githubusercontent.com/fdumbioinfo/rtools/main/moal-demo/0-moal-install-r-universe.r")
library(moal)
# change working directory to data_analysis folder
setwd(".")
# input data
"inputdata/3-normd... |
634a536bbffb5711315acb4a5cdf2f9fc44b9703f89a2c5e9e3f0f13a4401934 | R | 1,273 | 23 | #' @title exportsForArboreto (alias: exportsForGRNBoost)
#' @description Exports the TF list and expression matrix to text format to run GRNBoost (https://arboreto.readthedocs.io).
#' Note that it is also possible to run the full pipeline of SCENIC in python. See https://pyscenic.readthedocs.io
#' @param exprMat Expres... |
a73555089a5d5cc41c9fb56e4ac55e415dec1585d6d9764df2f68143ac7878e0 | R | 1,273 | 39 | library(tidyverse)
load("GTEx_DLPFC_regressed.RData")
prsCor = function(i, gene, datExpr) {
c <- cor.test(datExpr[i,], datExpr[gene,], use = 'pairwise.complete.obs')
dfPrs <- data.frame(Gene = rownames(datExpr)[i], R = c$estimate, P = c$p.value)
return(dfPrs)
}
data <- read.table("HMAG_genes.txt", header=FALSE) %... |
bab71028a4f56d6803adad052ffdaff7c2348ce2389802413255fa5d6fe8ca07 | R | 1,276 | 54 | # single-cell analysis package
library(Seurat)
# plotting and data science packages
library(tidyverse)
library(cowplot)
library(patchwork)
# co-expression network analysis packages:
library(WGCNA)
library(hdWGCNA)
# network analysis & visualization package:
library(igraph)
# using the cowplot theme for ggplot
theme... |
f418b94f723fb601dd542c408048c62ff707a191316c11d0b6824bb2892a4a03 | R | 1,277 | 38 |
library(epicalc)
args<-commandArgs(TRUE)
viruses_csv = sprintf("%s", args[1]) #FAP/HPV.csv
complete_HPV = sprintf("%s", args[2]) #FAP/complete_HPV.blast_results
ref_clone_HPV = sprintf("%s", args[3]) #/media/storage/HTS/HPV_center/ref_clones.csv
accession_to_gi_translator = sprintf("%s", args[4]) #/media/storage/HTS... |
906b35d24ec17a743f175c17c87eba2f47d93b6c417953889d18a436210ab0a1 | R | 1,280 | 38 | # draw distribution of length of introgressed segments in ab and ba directions
# the script will look for the files:
# - ab_introgressed_095.merged.bed
# - ba_introgressed_095.merged.bed
# inside of the folder specified as first positional arguments
# the second positional argument will define the output folder for t... |
da648939270ac0aaec2cba4e83952ed813d48c55714bbbea873ebaae6f999997 | R | 1,283 | 32 | ## Did you miss the previous step? The one about setting up the R package core
## files.
rstudioapi::navigateToFile(usethis::proj_path("dev", "03_core_files.R"))
## ********************************************
## Update your package code before a git commit
## ********************************************
## Automatic... |
3186f892cbcf282e4a22465856ae66268c4aa5a6860ce240cc2dcf3639203a5b | R | 1,284 | 30 | plotGGHeatmap <- function(df, legend.title="") {
df %<>% tibble::as_tibble(rownames=".id.") %>%
reshape2::melt(id.vars=".id.") %>%
dplyr::mutate(.id.=factor(.id., levels=rev(rownames(df))), variable=factor(variable, levels=colnames(df)))
ggplot(df) + geom_tile(aes(x=variable, y=.id., fill=value), colour = ... |
879be4c259f6f84ef93e7da2a19e21b37981f89d09283eb0a50bad0f52c85beb | R | 1,288 | 38 | # When working with lM it is useful to design an "average and difference"
# contrast matrix, which for binary responses has a simple canonical from:
ADmat <- matrix(c(-1/2,1/2),ncol=1,dimnames=list(NULL,"d"))
# We also define a match function for lM
matchfun=function(d)d$S==d$lR
# Drop most subjects
dat <- forstmann[... |
a33d700616bb31dbfc947d45725dc2f3b6f3844f2fe2ccf80dc4d00380f0f829 | R | 1,291 | 38 |
#' Compute subject-wise and group-wise averages and residuals for a searchlight domain
#'
#' This function takes the output of select_searchlight_domain and computes:
#' - subject-wise mean within the domain (handling single/multiple vertices per subject)
#' - group mean within the domain
#' - subject-wise residuals ... |
8d57847a753a49f85359765693ffe7c1b1955d2e1724825f551c1169ea2b8d63 | R | 1,293 | 45 | library(Seurat)
library(scater)
library(iSC.MEB)
library(SingleCellExperiment)
library(anndata)
path <- "./ST.h5ad"
ST <- read_h5ad(path)
#Number of clusters
q <- length(unique(ST$obs$ground_truth))
ST$var_names_make_unique()
counts <- t(ST$X)
x<- ST$obs$array_row
y<- ST$obs$array_col
spatial_location_anndata<- data... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.