### Install scTenifoldNet in R Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Install the scTenifoldNet package using the install.packages function in an R shell. ```R install.packages("scTenifoldNet") ``` -------------------------------- ### Install scTenifoldNet in MATLAB Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Download, unzip, and add the scTenifoldNet MATLAB package to the path. This code also includes basic checks for successful installation. ```MATLAB tic disp('Installing scTenifoldNet...') unzip('https://github.com/cailab-tamu/scTenifoldNet/archive/master.zip'); addpath('./scTenifoldNet-master/MATLAB'); toc if exist('sctenifoldnet_m.m','file') disp('scTenifoldNet installed!') end ``` -------------------------------- ### Install scTenifoldKnk in MATLAB Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldknk.html Downloads and adds the scTenifoldKnk repository to the MATLAB path. ```MATLAB tic disp('Installing scTenifoldKnk...') unzip('https://github.com/cailab-tamu/scTenifoldKnk/archive/master.zip'); addpath('./scTenifoldKnk-master/MATLAB'); toc if exist('sctenifoldknk.m','file') disp('scTenifoldKnk installed!') end ``` -------------------------------- ### Install scTenifoldNet in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Install the ScTenifold.jl package from a Git repository URL or add it directly using the Julia package manager. Testing the package is also included. ```Julia using Pkg Pkg.add(PackageSpec(url="git://github.com/jamesjcai/ScTenifold.jl.git")) Pkg.test("ScTenifold") # or # ] add https://github.com/jamesjcai/ScTenifoldNet.jl ``` -------------------------------- ### Basic Use of scTenifoldNet in MATLAB Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Load example data, perform quality control and filtering, extract control and perturbed cell populations, compute the gene regulatory network, save results, and identify differentially regulated genes. This example also demonstrates loading and comparing adjacency matrices for visualization. ```MATLAB load clean_data_1Ctl_2FgF2.mat sce=sce.selectgenes(1,0.15); sce=sce.qcfilter; %% X0=sce.X(:,sce.c_batch_id==1); X1=sce.X(:,sce.c_batch_id==2); T=sctenifoldnet(X0,X1,sce.g,'savegrn',true); writetable(T,'resT.txt'); Tr=e_fgsearun(T); writetable(Tr,'resTr.txt'); tgenes=T.genelist(T.pAdjusted<0.1); e_fgseanet(Tr); load(ls('A0_*.mat')) [y,i]=isemember(tgenes,genelist); assert(all(y)) a0=A0(i,i); load(ls('A1_*.mat')) [y,i]=isemember(tgenes,genelist); assert(all(y)) a1=A1(i,i); g1=digraph(a1,tgenes,'omitselfloops'); g2=digraph(a2,tgenes,'omitselfloops'); gui.i_doublegraphs(g1,g2); ``` -------------------------------- ### Basic Use of scTenifoldNet in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Generate random expression matrices, simulate a perturbation, and run the sctenifoldnet function to compute differential networks. The results are then saved to a text file. Note that normalization is disabled in this example. ```Julia using ScTenifold using DelimitedFiles # cd(dirname(@__FILE__)) X1=rand(100,1000); X2=copy(X1); X2[4,:].=0.0; @time d,fc,p,adjp=ScTenifold.sctenifoldnet(X1,X2,donorm=false) open("output_small.txt", "w") do io writedlm(io, [d fc p adjp]) end ``` -------------------------------- ### Load ScTenifoldNet in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Load the ScTenifoldNet.jl package into the current Julia session using the 'using' keyword. ```Julia using ScTenifoldNet ``` -------------------------------- ### Simulate a Dataset in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Simulate a gene expression dataset with 100 genes and 2000 cells using a negative binomial distribution, resulting in high sparsity. ```Julia d=NegativeBinomial(20,0.98) X=rand(d,100,2000) ``` -------------------------------- ### Basic Use of scTenifoldNet in R Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Load libraries, read data from CSV files, convert to matrices, set row names, run scTenifoldNet, save the results, and write differential regulation to a CSV file. Ensure 'X1.csv', 'X2.csv', and 'genelist.csv' are in the working directory. ```R library(scTenifoldNet) library(Matrix) X <- read.csv('X1.csv', header = FALSE) colnames(X) <- paste0('X1_', seq_len(ncol(X))) X <- as.matrix(X) Y <- read.csv('X2.csv', header = FALSE) colnames(Y) <- paste0('X2_', seq_len(ncol(Y))) Y <- as.matrix(Y) rownames(X) <- rownames(Y) <- readLines('genelist.csv') set.seed(1) DR <- scTenifoldNet(X = X, Y = Y) save(DR, file = 'netOut.RData') write.csv(DR$diffRegulation, row.names = FALSE, file = 'netResult.csv') ``` -------------------------------- ### Plotting Results with QQ Plot in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Generate a quantile-quantile plot to visualize the distribution of differential gene regulation results (fc) against a theoretical Chi-squared distribution. Requires StatsPlots and Distributions packages. ```Julia using StatsPlots, Distributions x=rand(Chisq(1), length(fc)) qqplot(x, fc) ``` -------------------------------- ### Generate Networks using tenrnet in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Construct gene regulatory networks (GRNs) using the tenrnet function. Z0 is generated from the control data (X) and Z1 from the perturbed data (Y), with normalization enabled. ```Julia Z0=ScTenifoldNet.tenrnet(X, donorm=true) Z1=ScTenifoldNet.tenrnet(Y, donorm=true) ``` -------------------------------- ### Generate a Perturbed Network in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Create a perturbed gene expression matrix 'Y' by copying 'X' and then replacing the expression of specific genes (10, 2, 3) with that of other genes (50, 11, 5). Cells with low total expression are then filtered out from both matrices. ```Julia Y=copy(X) Y[10,:]=Y[50,:] Y[2,:]=Y[11,:] Y[3,:]=Y[5,:] X=X[:,vec(sum(X,dims=1).>30)] Y=Y[:,vec(sum(Y,dims=1).>30)] ``` -------------------------------- ### Differential Regulation Analysis in Julia Source: https://sctenifold.readthedocs.io/en/latest/sctenifoldnet.html Perform manifold alignment between the control (Z0) and perturbed (Z1) networks to obtain distance (d), alignment matrices (aln0, aln1), fold changes (fc), p-values (p), and adjusted p-values (adjp) for differential gene regulation. ```Julia d,aln0,aln1=ScTenifoldNet.manialn(Z0,Z1) fc,p,adjp=ScTenifoldNet.drgenes(d) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.