Entering edit mode
9 weeks ago
maryak
▴
20
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("TCGAbiolinks", force = TRUE)
library(edgeR)
library(SummarizedExperiment)
library(TCGAbiolinks)
BiocManager::install("edgeR")
#install.packages("DMwR")
#library(DMwR)
BiocManager::install("minfi")
library(minfi)
library(limma)
library(dplyr)
# Load necessary libraries
library(edgeR)
library(readr)
# Load raw count data
metastatic <- read.csv("C:\\Users\\222307\\Documents\\metastaticCOAD.csv", row.names = 1)
non_metastatic <- read.csv("C:\\Users\\222307\\Documents\\non_metastaticCOAD.csv", row.names = 1)
# Merge datasets
count_data <- cbind(metastatic, non_metastatic)
# Create group labels
group <- factor(c(rep("Metastatic", ncol(metastatic)), rep("NonMetastatic", ncol(non_metastatic))))
dge <- DGEList(counts = count_data, group = group)
keep <- filterByExpr(dge)
dge <- dge[keep, , keep.lib.sizes=FALSE]
dge <- calcNormFactors(dge, method = "TMM")
design <- model.matrix(~group)
dge <- estimateDisp(dge, design)
fit <- glmFit(dge, design)
lrt <- glmLRT(fit, coef=2) # Compare metastatic vs non-metastatic
results <- topTags(lrt, n = Inf) # Extract all genes
write.csv(results, "C:\\Users\\22232347\\Documents\\differential_expression_results.csv", row.names = TRUE)
#plotBCV(dge)
is my code for differential analysis correct ? how i know the genes i obtained are correct?
Please read the edgeR user guide that contains guidance.
If you follow the guide you have a good chance it is formally correct. If it is biologically correct in terms of meaningful you never know. That is why one would do validation experiments.