Skip to content
Snippets Groups Projects
Commit 1d4b3984 authored by yunusek77's avatar yunusek77
Browse files

Update 8 files

- /DGE/Deseq2/miRNA/GSE55857 miRNA errors.R
- /DGE/Deseq2/miRNA/GSE43732_miRNA.R
- /DGE/Deseq2/miRNA/GSE6188 miRNA.R
- /DGE/Deseq2/mRNA/.Rhistory
- /DGE/Limma/miRNA/.Rhistory
- /MultiMIR/multimir_results.xlsx
- /DGE/Limma/miRNA/GSE6188.R
- /README.md
parent e12dcd4b
No related branches found
No related tags found
No related merge requests found
library(GEOquery)
library(tidyverse)
library(magrittr)
mRNA_GSE20347 <- getGEO("GSE20347", GSEMatrix =TRUE, AnnotGPL=TRUE,getGPL= T)
if (length(mRNA_GSE20347) > 1) idx <- grep("GPL4508", attr(mRNA_GSE20347, "names")) else idx <- 1
mRNA_GSE20347 <- mRNA_GSE20347[[idx]]
GSE20347<- mRNA_GSE20347@assayData[["exprs"]]
colx<- mRNA_GSE20347@featureData@data[["Gene symbol"]]
GSE20347<- cbind(colx,GSE20347)
# Convert matrix to a dataframe
df_GSE20347 <- as.data.frame(GSE20347)
library(DESeq2)
# Extract only the count matrix
count_matrix <- df_GSE20347[, 2:ncol(df_GSE20347)]
# Sample information
sample_names <- colnames(count_matrix)
# Create the sample_info data frame
conditions <- c(rep("normal adjacent esophageal tissue", 17), rep("esophageal squamous cell carcinoma", length(sample_names) - 17))
sample_info <- data.frame(Sample = sample_names, Condition = conditions)
#### SKIRMISH FOR DESEQ2 DATASET ###########
count_matrix <- as.matrix(sapply(count_matrix, as.numeric))
count_matrix <- count_matrix[complete.cases(count_matrix), ]
count_matrix <- round(count_matrix)
#get rownames of previous data
row_names_GSE20347 <- rownames(GSE20347)
# Set gene_id to rownames again
rownames(count_matrix) <- row_names_GSE20347
# Create the DESeqDataSet using the updated sample_info
dds <- DESeqDataSetFromMatrix(countData = count_matrix,
colData = sample_info,
design = ~ Condition)
# Perform differential gene expression analysis
dds <- DESeq(dds)
resultsNames(dds)
par(mar=c(8,5,2,2))
boxplot(log10(assays(dds)[["cooks"]]), range=0, las=2)
res <- results(dds, name="Condition_normal.adjacent.esophageal.tissue_vs_esophageal.squamous.cell.carcinoma")
summary(res)
# Adjustment to overcome NA-error --> exclude rows containing NA's
filtered_indices <- which(res$log2FoldChange < 1 & res$log2FoldChange > -1 & res$padj < 0.05 & !is.na(res$padj))
filtered_downregulated_genes <- res[filtered_indices, ]
gene_names <- rownames(filtered_downregulated_genes)
gene_names
res2 <- results(dds, name = "Condition_normal.adjacent.esophageal.tissue_vs_esophageal.squamous.cell.carcinoma")
# Convert p-value to -log10(p-value)
res2$log10_pvalue <- -log10(res2$pvalue)
# Create the volcano plot
volcano_plot <- ggplot(data = res2, aes(x = log2FoldChange, y = log10_pvalue)) +
geom_point() +
labs(x = "log2 Fold Change", y = "-log10 p-value") +
theme_minimal()
# Display the volcano plot
print(volcano_plot)
res2 <- results(dds, name = "Condition_normal.adjacent.esophageal.tissue_vs_esophageal.squamous.cell.carcinoma")
# Convert p-value to -log10(p-value)
res2$log10_pvalue <- -log10(res2$pvalue)
# Create the volcano plot
volcano_plot <- ggplot(data = res2, aes(x = log2FoldChange, y = log10_pvalue)) +
geom_point() +
labs(x = "log2 Fold Change", y = "-log10 p-value") +
theme_minimal()
library(GEOquery)
library(tidyverse)
library(magrittr)
library(DESeq2)
library(ggrepel)
mRNA_GSE20347 <- getGEO("GSE20347", GSEMatrix = TRUE, AnnotGPL = TRUE, getGPL = TRUE)
if (length(mRNA_GSE20347) > 1) idx <- grep("GPL4508", attr(mRNA_GSE20347, "names")) else idx <- 1
mRNA_GSE20347 <- mRNA_GSE20347[[idx]]
GSE20347 <- mRNA_GSE20347@assayData[["exprs"]]
colx <- mRNA_GSE20347@featureData@data[["Gene symbol"]]
GSE20347 <- cbind(colx, GSE20347)
# Convert matrix to a dataframe
df_GSE20347 <- as.data.frame(GSE20347)
# Extract only the count matrix
count_matrix <- df_GSE20347[, 2:ncol(df_GSE20347)]
# Sample information
sample_names <- colnames(count_matrix)
# Create the sample_info data frame
conditions <- c(rep("normal adjacent esophageal tissue", 17), rep("esophageal squamous cell carcinoma", length(sample_names) - 17))
sample_info <- data.frame(Sample = sample_names, Condition = conditions)
#### SKIRMISH FOR DESEQ2 DATASET ###########
count_matrix <- as.matrix(sapply(count_matrix, as.numeric))
count_matrix <- count_matrix[complete.cases(count_matrix), ]
count_matrix <- round(count_matrix)
# Get rownames of previous data
row_names_GSE20347 <- rownames(GSE20347)
# Set gene_id to rownames again
rownames(count_matrix) <- row_names_GSE20347
# Create the DESeqDataSet using the updated sample_info
dds <- DESeqDataSetFromMatrix(countData = count_matrix,
colData = sample_info,
design = ~ Condition)
# Perform differential gene expression analysis
dds <- DESeq(dds)
# Volcano plot
res <- results(dds)
res$logPadj <- -log10(res$padj)
res$logFC <- res$log2FoldChange
res$Sig <- ifelse(abs(res$log2FoldChange) > 1 & res$padj < 0.05, "Yes", "No")
# Plot volcano plot
ggplot(res, aes(x = logFC, y = logPadj, color = Sig)) +
geom_point(alpha = 0.6) +
geom_hline(yintercept = -log10(0.05), linetype = "dashed", color = "red") +
geom_vline(xintercept = c(-1, 1), linetype = "dashed", color = "blue") +
xlim(c(-max(abs(res$log2FoldChange)), max(abs(res$log2FoldChange)))) +
labs(x = "log2 Fold Change", y = "-log10(Adjusted p-value)", title = "Volcano Plot") +
theme_minimal() +
theme(legend.position = "none")
library(GEOquery)
library(tidyverse)
library(magrittr)
mRNA_GSE20347 <- getGEO("GSE20347", GSEMatrix =TRUE, AnnotGPL=TRUE,getGPL= T)
if (length(mRNA_GSE20347) > 1) idx <- grep("GPL4508", attr(mRNA_GSE20347, "names")) else idx <- 1
mRNA_GSE20347 <- mRNA_GSE20347[[idx]]
GSE20347<- mRNA_GSE20347@assayData[["exprs"]]
colx<- mRNA_GSE20347@featureData@data[["Gene symbol"]]
GSE20347<- cbind(colx,GSE20347)
# Convert matrix to a dataframe
df_GSE20347 <- as.data.frame(GSE20347)
library(DESeq2)
# Extract only the count matrix
count_matrix <- df_GSE20347[, 2:ncol(df_GSE20347)]
# Sample information
sample_names <- colnames(count_matrix)
# Create the sample_info data frame
conditions <- c(rep("normal adjacent esophageal tissue", 17), rep("esophageal squamous cell carcinoma", length(sample_names) - 17))
sample_info <- data.frame(Sample = sample_names, Condition = conditions)
#### SKIRMISH FOR DESEQ2 DATASET ###########
count_matrix <- as.matrix(sapply(count_matrix, as.numeric))
count_matrix <- count_matrix[complete.cases(count_matrix), ]
count_matrix <- round(count_matrix)
#get rownames of previous data
row_names_GSE20347 <- rownames(GSE20347)
# Set gene_id to rownames again
rownames(count_matrix) <- row_names_GSE20347
# Create the DESeqDataSet using the updated sample_info
dds <- DESeqDataSetFromMatrix(countData = count_matrix,
colData = sample_info,
design = ~ Condition)
# Perform differential gene expression analysis
dds <- DESeq(dds)
resultsNames(dds)
par(mar=c(8,5,2,2))
boxplot(log10(assays(dds)[["cooks"]]), range=0, las=2)
res <- results(dds, name="Condition_normal.adjacent.esophageal.tissue_vs_esophageal.squamous.cell.carcinoma")
summary(res)
# Adjustment to overcome NA-error --> exclude rows containing NA's
filtered_indices <- which(res$log2FoldChange < 1 & res$log2FoldChange > -1 & res$padj < 0.05 & !is.na(res$padj))
filtered_downregulated_genes <- res[filtered_indices, ]
gene_names <- rownames(filtered_downregulated_genes)
gene_names
res2 <- as.data.frame(results(dds, name = "Condition_normal.adjacent.esophageal.tissue_vs_esophageal.squamous.cell.carcinoma"))
# Convert p-value to -log10(p-value)
res2$log10_pvalue <- -log10(res2$pvalue)
# Create the volcano plot
volcano_plot <- ggplot(data = res2, aes(x = log2FoldChange, y = log10_pvalue)) +
geom_point() +
labs(x = "log2 Fold Change", y = "-log10 p-value") +
theme_minimal()
# Display the volcano plot
print(volcano_plot)
# Add vertical lines for fold change thresholds
volcano_plot <- volcano_plot +
geom_vline(xintercept = c(-1, 1), color = "red") +
geom_hline(yintercept = -log10(0.05), color = "red")
# Display the customized volcano plot
print(volcano_plot)
# Version info: R 4.2.2, Biobase 2.58.0, GEOquery 2.66.0, limma 3.54.0
################################################################
# Differential expression analysis with limma
library(GEOquery)
library(limma)
library(umap)
gset <- getGEO("GSE20347", GSEMatrix =TRUE, AnnotGPL=TRUE)
if (length(gset) > 1) idx <- grep("GPL571", attr(gset, "names")) else idx <- 1
gset <- gset[[idx]]
# make proper column names to match toptable
fvarLabels(gset) <- make.names(fvarLabels(gset))
# group membership for all samples
gsms <- "0000000000000000011111111111111111"
sml <- strsplit(gsms, split="")[[1]]
# log2 transformation
ex <- exprs(gset)
qx <- as.numeric(quantile(ex, c(0., 0.25, 0.5, 0.75, 0.99, 1.0), na.rm=T))
LogC <- (qx[5] > 100) ||
(qx[6]-qx[1] > 50 && qx[2] > 0)
if (LogC) { ex[which(ex <= 0)] <- NaN
exprs(gset) <- log2(ex) }
# assign samples to groups and set up design matrix
gs <- factor(sml)
groups <- make.names(c("normal","cancer"))
levels(gs) <- groups
gset$group <- gs
design <- model.matrix(~group + 0, gset)
colnames(design) <- levels(gs)
gset <- gset[complete.cases(exprs(gset)), ] # skip missing values
fit <- lmFit(gset, design) # fit linear model
# set up contrasts of interest and recalculate model coefficients
cts <- c(paste(groups[1],"-",groups[2],sep=""))
cont.matrix <- makeContrasts(contrasts=cts, levels=design)
fit2 <- contrasts.fit(fit, cont.matrix)
# compute statistics and table of top significant genes
fit2 <- eBayes(fit2, 0.01)
tT <- topTable(fit2, adjust="fdr", sort.by="B", number=250)
tT <- subset(tT, select=c("ID","adj.P.Val","P.Value","t","B","logFC","GB_ACC","SPOT_ID","Gene.Symbol","Gene.symbol","Gene.title"))
write.table(tT, file=stdout(), row.names=F, sep="\t")
# Visualize and quality control test results.
# Build histogram of P-values for all genes. Normal test
# assumption is that most genes are not differentially expressed.
tT2 <- topTable(fit2, adjust="fdr", sort.by="B", number=Inf)
hist(tT2$adj.P.Val, col = "grey", border = "white", xlab = "P-adj",
ylab = "Number of genes", main = "P-adj value distribution")
# summarize test results as "up", "down" or "not expressed"
dT <- decideTests(fit2, adjust.method="fdr", p.value=0.05, lfc=1)
# Venn diagram of results
vennDiagram(dT, circle.col=palette())
# create Q-Q plot for t-statistic
t.good <- which(!is.na(fit2$F)) # filter out bad probes
qqt(fit2$t[t.good], fit2$df.total[t.good], main="Moderated t statistic")
# volcano plot (log P-value vs log fold change)
colnames(fit2) # list contrast names
ct <- 1 # choose contrast of interest
volcanoplot(fit2, coef=ct, main=colnames(fit2)[ct], pch=20,
highlight=length(which(dT[,ct]!=0)), names=rep('+', nrow(fit2)))
View(tT2)
View(tT)
volcanoplot(fit2, coef=ct, main=colnames(fit2)[ct], pch=20,
highlight=length(which(dT[,ct]!=0)), names=rep('+', nrow(fit2)))
# MD plot (log fold change vs mean log expression)
# highlight statistically significant (p-adj < 0.05) probes
plotMD(fit2, column=ct, status=dT[,ct], legend=F, pch=20, cex=1)
abline(h=0)
################################################################
# General expression data analysis
ex <- exprs(gset)
# box-and-whisker plot
dev.new(width=3+ncol(gset)/6, height=5)
ord <- order(gs) # order samples by group
palette(c("#1B9E77", "#7570B3", "#E7298A", "#E6AB02", "#D95F02",
"#66A61E", "#A6761D", "#B32424", "#B324B3", "#666666"))
library(GEOquery)
library(limma)
library(umap)
gset <- getGEO("GSE43732", GSEMatrix =TRUE, AnnotGPL=FALSE)
if (length(gset) > 1) idx <- grep("GPL16543", attr(gset, "names")) else idx <- 1
gset <- gset[[idx]]
# make proper column names to match toptable
fvarLabels(gset) <- make.names(fvarLabels(gset))
# group membership for all samples
gsms <- paste0("11110000111100001111000011110000111100001111000011",
"11000011110000111100001111000011110000111100001111",
"00001111000011110000111100000111100011110000111100",
"00111100001011110000111100001111000011110000111100",
"00111000111100001111000011100011110000")
sml <- strsplit(gsms, split="")[[1]]
# log2 transformation
ex <- exprs(gset)
qx <- as.numeric(quantile(ex, c(0., 0.25, 0.5, 0.75, 0.99, 1.0), na.rm=T))
LogC <- (qx[5] > 100) ||
(qx[6]-qx[1] > 50 && qx[2] > 0)
if (LogC) { ex[which(ex <= 0)] <- NaN
exprs(gset) <- log2(ex) }
# assign samples to groups and set up design matrix
gs <- factor(sml)
groups <- make.names(c("Normal","Cancer"))
levels(gs) <- groups
gset$group <- gs
design <- model.matrix(~group + 0, gset)
colnames(design) <- levels(gs)
gset <- gset[complete.cases(exprs(gset)), ] # skip missing values
fit <- lmFit(gset, design) # fit linear model
# set up contrasts of interest and recalculate model coefficients
cts <- paste(groups[1], groups[2], sep="-")
cont.matrix <- makeContrasts(contrasts=cts, levels=design)
fit2 <- contrasts.fit(fit, cont.matrix)
# compute statistics and table of top significant genes
fit2 <- eBayes(fit2, 0.01)
tT <- topTable(fit2, adjust="fdr", sort.by="B", number=250)
tT <- subset(tT, select=c("ID","adj.P.Val","P.Value","t","B","logFC","SPOT_ID","miRNA_ID"))
write.table(tT, file=stdout(), row.names=F, sep="\t")
# Visualize and quality control test results.
# Build histogram of P-values for all genes. Normal test
# assumption is that most genes are not differentially expressed.
tT2 <- topTable(fit2, adjust="fdr", sort.by="B", number=Inf)
hist(tT2$adj.P.Val, col = "grey", border = "white", xlab = "P-adj",
ylab = "Number of genes", main = "P-adj value distribution")
# summarize test results as "up", "down" or "not expressed"
dT <- decideTests(fit2, adjust.method="fdr", p.value=0.05, lfc=1)
# Venn diagram of results
vennDiagram(dT, circle.col=palette())
# create Q-Q plot for t-statistic
t.good <- which(!is.na(fit2$F)) # filter out bad probes
qqt(fit2$t[t.good], fit2$df.total[t.good], main="Moderated t statistic")
# volcano plot (log P-value vs log fold change)
colnames(fit2) # list contrast names
ct <- 1 # choose contrast of interest
volcanoplot(fit2, coef=ct, main=colnames(fit2)[ct], pch=20,
highlight=length(which(dT[,ct]!=0)), names=rep('+', nrow(fit2)))
# MD plot (log fold change vs mean log expression)
# highlight statistically significant (p-adj < 0.05) probes
plotMD(fit2, column=ct, status=dT[,ct], legend=F, pch=20, cex=1)
abline(h=0)
################################################################
# General expression data analysis
ex <- exprs(gset)
# box-and-whisker plot
dev.new(width=3+ncol(gset)/6, height=5)
ord <- order(gs) # order samples by group
palette(c("#1B9E77", "#7570B3", "#E7298A", "#E6AB02", "#D95F02",
"#66A61E", "#A6761D", "#B32424", "#B324B3", "#666666"))
par(mar=c(7,4,2,1))
title <- paste ("GSE43732", "/", annotation(gset), sep ="")
boxplot(ex[,ord], boxwex=0.6, notch=T, main=title, outline=FALSE, las=2, col=gs[ord])
legend("topleft", groups, fill=palette(), bty="n")
dev.off()
# expression value distribution
par(mar=c(4,4,2,1))
title <- paste ("GSE43732", "/", annotation(gset), " value distribution", sep ="")
plotDensities(ex, group=gs, main=title, legend ="topright")
# UMAP plot (dimensionality reduction)
ex <- na.omit(ex) # eliminate rows with NAs
ex <- ex[!duplicated(ex), ] # remove duplicates
ump <- umap(t(ex), n_neighbors = 15, random_state = 123)
par(mar=c(3,3,2,6), xpd=TRUE)
plot(ump$layout, main="UMAP plot, nbrs=15", xlab="", ylab="", col=gs, pch=20, cex=1.5)
legend("topright", inset=c(-0.15,0), legend=levels(gs), pch=20,
col=1:nlevels(gs), title="Group", pt.cex=1.5)
library("maptools") # point labels without overlaps
pointLabel(ump$layout, labels = rownames(ump$layout), method="SANN", cex=0.6)
# mean-variance trend, helps to see if precision weights are needed
plotSA(fit2, main="Mean variance trend, GSE43732")
# Version info: R 4.2.2, Biobase 2.58.0, GEOquery 2.66.0, limma 3.54.0
################################################################
# Differential expression analysis with limma
library(GEOquery)
library(limma)
library(umap)
gset <- getGEO("GSE43732", GSEMatrix =TRUE, AnnotGPL=FALSE)
if (length(gset) > 1) idx <- grep("GPL16543", attr(gset, "names")) else idx <- 1
gset <- gset[[idx]]
# make proper column names to match toptable
fvarLabels(gset) <- make.names(fvarLabels(gset))
# group membership for all samples
gsms <- paste0("00001111000011110000111100001111000011110000111100",
"00111100001111000011110000111100001111000011110000",
"11110000111100001111000011111000011100001111000011",
"11000011110100001111000011110000111100001111000011",
"11000111000011110000111100011100001111")
sml <- strsplit(gsms, split="")[[1]]
# log2 transformation
ex <- exprs(gset)
qx <- as.numeric(quantile(ex, c(0., 0.25, 0.5, 0.75, 0.99, 1.0), na.rm=T))
LogC <- (qx[5] > 100) ||
(qx[6]-qx[1] > 50 && qx[2] > 0)
if (LogC) { ex[which(ex <= 0)] <- NaN
exprs(gset) <- log2(ex) }
# assign samples to groups and set up design matrix
gs <- factor(sml)
groups <- make.names(c("cancer","normal"))
levels(gs) <- groups
gset$group <- gs
design <- model.matrix(~group + 0, gset)
colnames(design) <- levels(gs)
gset <- gset[complete.cases(exprs(gset)), ] # skip missing values
fit <- lmFit(gset, design) # fit linear model
# set up contrasts of interest and recalculate model coefficients
cts <- paste(groups[1], groups[2], sep="-")
cont.matrix <- makeContrasts(contrasts=cts, levels=design)
fit2 <- contrasts.fit(fit, cont.matrix)
# compute statistics and table of top significant genes
fit2 <- eBayes(fit2, 0.01)
tT <- topTable(fit2, adjust="fdr", sort.by="B", number=250)
tT <- subset(tT, select=c("ID","adj.P.Val","P.Value","t","B","logFC","SPOT_ID","miRNA_ID"))
write.table(tT, file=stdout(), row.names=F, sep="\t")
# Visualize and quality control test results.
# Build histogram of P-values for all genes. Normal test
# assumption is that most genes are not differentially expressed.
tT2 <- topTable(fit2, adjust="fdr", sort.by="B", number=Inf)
hist(tT2$adj.P.Val, col = "grey", border = "white", xlab = "P-adj",
ylab = "Number of genes", main = "P-adj value distribution")
# summarize test results as "up", "down" or "not expressed"
dT <- decideTests(fit2, adjust.method="fdr", p.value=0.05, lfc=0)
# Venn diagram of results
vennDiagram(dT, circle.col=palette())
# create Q-Q plot for t-statistic
t.good <- which(!is.na(fit2$F)) # filter out bad probes
qqt(fit2$t[t.good], fit2$df.total[t.good], main="Moderated t statistic")
# volcano plot (log P-value vs log fold change)
colnames(fit2) # list contrast names
ct <- 1 # choose contrast of interest
volcanoplot(fit2, coef=ct, main=colnames(fit2)[ct], pch=20,
highlight=length(which(dT[,ct]!=0)), names=rep('+', nrow(fit2)))
# MD plot (log fold change vs mean log expression)
# highlight statistically significant (p-adj < 0.05) probes
plotMD(fit2, column=ct, status=dT[,ct], legend=F, pch=20, cex=1)
abline(h=0)
################################################################
# General expression data analysis
ex <- exprs(gset)
# box-and-whisker plot
dev.new(width=3+ncol(gset)/6, height=5)
ord <- order(gs) # order samples by group
palette(c("#1B9E77", "#7570B3", "#E7298A", "#E6AB02", "#D95F02",
"#66A61E", "#A6761D", "#B32424", "#B324B3", "#666666"))
par(mar=c(7,4,2,1))
title <- paste ("GSE43732", "/", annotation(gset), sep ="")
boxplot(ex[,ord], boxwex=0.6, notch=T, main=title, outline=FALSE, las=2, col=gs[ord])
legend("topleft", groups, fill=palette(), bty="n")
dev.off()
# expression value distribution
par(mar=c(4,4,2,1))
title <- paste ("GSE43732", "/", annotation(gset), " value distribution", sep ="")
plotDensities(ex, group=gs, main=title, legend ="topright")
# UMAP plot (dimensionality reduction)
ex <- na.omit(ex) # eliminate rows with NAs
ex <- ex[!duplicated(ex), ] # remove duplicates
ump <- umap(t(ex), n_neighbors = 15, random_state = 123)
par(mar=c(3,3,2,6), xpd=TRUE)
plot(ump$layout, main="UMAP plot, nbrs=15", xlab="", ylab="", col=gs, pch=20, cex=1.5)
legend("topright", inset=c(-0.15,0), legend=levels(gs), pch=20,
col=1:nlevels(gs), title="Group", pt.cex=1.5)
library("maptools") # point labels without overlaps
pointLabel(ump$layout, labels = rownames(ump$layout), method="SANN", cex=0.6)
# mean-variance trend, helps to see if precision weights are needed
plotSA(fit2, main="Mean variance trend, GSE43732")
library(GEOquery)
library(tidyverse)
library(magrittr)
library(multiMiR)
library(writexl)
miRNA_GSE43732 <- getGEO("GSE43732", GSEMatrix =TRUE, AnnotGPL=TRUE,getGPL= T)
if (length(miRNA_GSE43732) > 1) idx <- grep("GPL4508", attr(miRNA_GSE43732, "names")) else idx <- 1
miRNA_GSE43732 <- miRNA_GSE43732[[idx]]
GSE43732 <- miRNA_GSE43732@assayData[["exprs"]]
colx<- miRNA_GSE43732@featureData@data[["Name"]]
GSE43732 <- cbind(colx,GSE43732)
# Convert matrix to a dataframe
df_GSE43732 <- as.data.frame(GSE43732)
library(DESeq2)
# Extract only the count matrix
count_matrix <- df_GSE43732[, 1:ncol(df_GSE43732)]
# Sample information
sample_names <- colnames(count_matrix)
conditions = c("cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal")
sample_info <- data.frame(Sample = sample_names, condition = conditions)
#### SKIRMISH FOR DESEQ2 DATASET ###########
#make NA's to 0
count_matrix <- as.matrix(sapply(count_matrix, as.numeric))
count_matrix[is.na(count_matrix)] <- 0
count_matrix <- round(count_matrix)
#get rownames of previous data
row_names_GSE43732 <- rownames(GSE43732)
# Set gene_id to rownames again
rownames(count_matrix) <- row_names_GSE43732
#negative values to abs() --> simulate counts
count_matrix <- abs(count_matrix)
# Create the DESeqDataSet using the updated sample_info
dds <- DESeqDataSetFromMatrix(countData = count_matrix,
colData = sample_info,
design = ~ condition)
# Perform differential gene expression analysis
dds <- DESeq(dds)
resultsNames(dds)
par(mar=c(8,5,2,2))
boxplot(log10(assays(dds)[["cooks"]]), range=0, las=2)
res <- results(dds, name="condition_normal_vs_cancer")
summary(res)
# Adjustment to overcome NA-error --> exclude rows containing NA's
filtered_indices <- which(res$log2FoldChange > 1 & res$padj < 0.05 & !is.na(res$padj))
filtered_downregulated_genes <- res[filtered_indices, ]
gene_names <- rownames(filtered_downregulated_genes)
gene_names
multimir_results <- get_multimir(org = 'hsa',
mirna = gene_names,
table = 'validated',
summary = TRUE)
targets <- multimir_results@data
excel_file <- "C:/Users/Emre/Desktop/Bioinformatik/Bioinformatik 2.Semester Master/Data Science in the Life Sciences/Project/multimir_results.xlsx"
write_xlsx(targets, path = excel_file )
rld <- rlog(dds, blind=TRUE)
PCA1 <- plotPCA(rld, intgroup = "condition")
PCA1
vst <- assay(vst(dds))
p <- pca(vst, removeVar = 0.1)
screeplot(p, axisLabSize = 18, titleLabSize = 22)
biplot(p, showLoadings = TRUE,
labSize = 5, pointSize = 5, sizeLoadingsNames = 5)
library(GEOquery)
library(tidyverse)
library(magrittr)
library(DESeq2)
miRNA_GSE55856 <- getGEO("GSE55856", GSEMatrix =TRUE, AnnotGPL=TRUE,getGPL= T)
GSE55856 <- miRNA_GSE55856[["GSE55856_series_matrix.txt.gz"]]@assayData[["exprs"]]
GSE55856 <- cbind(colx,GSE55856)
# Convert matrix to a dataframe
df_GSE55856 <- as.data.frame(GSE55856)
# Extract only the count matrix
count_matrix <- df_GSE55856[, 1:ncol(df_GSE55856)]
# Sample information
sample_names <- colnames(count_matrix)
conditions = c("normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal", "tumor", "normal",
"normal", "tumor", "normal", "tumor", "normal", "tumor", "normal")
sample_info <- data.frame(Sample = sample_names, condition = conditions)
#### SKIRMISH FOR DESEQ2 DATASET ###########
#make NA's to 0
count_matrix <- as.matrix(sapply(count_matrix, as.numeric))
count_matrix[is.na(count_matrix)] <- 0
count_matrix <- round(count_matrix)
#get rownames of previous data
row_names_GSE55856 <- rownames(GSE55856)
# Set gene_id to rownames again
rownames(count_matrix) <- row_names_GSE55856
#negative values to abs() --> simulate counts
#count_matrix <- abs(count_matrix)
# Create the DESeqDataSet using the updated sample_info
dds <- DESeqDataSetFromMatrix(countData = count_matrix,
colData = sample_info,
design = ~ condition)
# Perform differential gene expression analysis
dds <- DESeq(dds)
resultsNames(dds)
res <- results(dds, name="condition_tumor_vs_normal")
summary(res)
# Adjustment to overcome NA-error --> exclude rows containing NA's
filtered_indices <- which(res$log2FoldChange > 1 & res$padj < 0.05 & !is.na(res$padj))
filtered_downregulated_genes <- res[filtered_indices, ]
gene_names <- rownames(filtered_downregulated_genes)
gene_names
rld <- rlog(dds, blind=TRUE)
PCA1 <- plotPCA(rld, intgroup = "condition")
PCA1
library(GEOquery)
library(tidyverse)
library(dplyr)
library(PCAtools)
library(DESeq2)
miRNA_GSE6188 <- getGEO("GSE6188", GSEMatrix =TRUE, AnnotGPL=TRUE,getGPL= T)
if (length(miRNA_GSE6188) > 1) idx <- grep("GPL4508", attr(miRNA_GSE6188, "names")) else idx <- 1
miRNA_GSE6188 <- miRNA_GSE6188[[idx]]
GSE6188 <- miRNA_GSE6188@assayData[["exprs"]]
colx<- miRNA_GSE6188@featureData@data[["Name"]]
GSE6188 <- cbind(colx,GSE6188)
# Convert matrix to a dataframe
df_GSE6188 <- as.data.frame(GSE6188)
df_GSE6188[is.na(df_GSE6188)] <- 0
# Group the data frame by 'colx' and calculate the mean for other columns
df_mean <- df_GSE6188 %>%
group_by(colx) %>%
summarise(everything(), mean, na.rm = TRUE)
# Extract only the count matrix
count_matrix <- df_GSE43732[, 1:ncol(df_GSE43732)]
# Sample information
sample_names <- colnames(count_matrix)
conditions = c("cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "normal", "normal", "normal",
"cancer", "cancer", "cancer", "cancer", "normal", "normal", "normal", "normal")
sample_info <- data.frame(Sample = sample_names, condition = conditions)
#### SKIRMISH FOR DESEQ2 DATASET ###########
#make NA's to 0
count_matrix <- as.matrix(sapply(count_matrix, as.numeric))
count_matrix[is.na(count_matrix)] <- 0
count_matrix <- round(count_matrix)
#get rownames of previous data
row_names_GSE43732 <- rownames(GSE43732)
# Set gene_id to rownames again
rownames(count_matrix) <- row_names_GSE43732
#negative values to abs() --> simulate counts
count_matrix <- abs(count_matrix)
# Create the DESeqDataSet using the updated sample_info
dds <- DESeqDataSetFromMatrix(countData = count_matrix,
colData = sample_info,
design = ~ condition)
# Perform differential gene expression analysis
dds <- DESeq(dds)
resultsNames(dds)
par(mar=c(8,5,2,2))
boxplot(log10(assays(dds)[["cooks"]]), range=0, las=2)
res <- results(dds, name="condition_normal_vs_cancer")
summary(res)
# Adjustment to overcome NA-error --> exclude rows containing NA's
filtered_indices <- which(res$log2FoldChange > 1 & res$padj < 0.05 & !is.na(res$padj))
filtered_downregulated_genes <- res[filtered_indices, ]
gene_names <- rownames(filtered_downregulated_genes)
gene_names
rld <- rlog(dds, blind=TRUE)
PCA1 <- plotPCA(rld, intgroup = "condition")
PCA1
vst <- assay(vst(dds))
p <- pca(vst, removeVar = 0.1)
screeplot(p, axisLabSize = 18, titleLabSize = 22)
biplot(p, showLoadings = TRUE,
labSize = 5, pointSize = 5, sizeLoadingsNames = 5)
\ No newline at end of file
This diff is collapsed.
# Version info: R 4.2.2, Biobase 2.58.0, GEOquery 2.66.0, limma 3.54.0
################################################################
# Differential expression analysis with limma
library(GEOquery) library(GEOquery)
library(limma) library(limma)
library(umap) library(umap)
# load series and platform data from GEO # load data from GEO
gset <- getGEO("GSE6188", GSEMatrix =TRUE, AnnotGPL=FALSE) gset <- getGEO("GSE6188", GSEMatrix =TRUE, AnnotGPL=FALSE)
if (length(gset) > 1) idx <- grep("GPL4508", attr(gset, "names")) else idx <- 1 if (length(gset) > 1) idx <- grep("GPL4508", attr(gset, "names")) else idx <- 1
...@@ -31,7 +28,7 @@ LogC <- (qx[5] > 100) || ...@@ -31,7 +28,7 @@ LogC <- (qx[5] > 100) ||
if (LogC) { ex[which(ex <= 0)] <- NaN if (LogC) { ex[which(ex <= 0)] <- NaN
exprs(gset) <- log2(ex) } exprs(gset) <- log2(ex) }
# assign samples to groups and set up design matrix # assign samples and set up design matrix
gs <- factor(sml) gs <- factor(sml)
groups <- make.names(c("Normal","Cancer")) groups <- make.names(c("Normal","Cancer"))
levels(gs) <- groups levels(gs) <- groups
...@@ -43,7 +40,7 @@ gset <- gset[complete.cases(exprs(gset)), ] # skip missing values ...@@ -43,7 +40,7 @@ gset <- gset[complete.cases(exprs(gset)), ] # skip missing values
fit <- lmFit(gset, design) # fit linear model fit <- lmFit(gset, design) # fit linear model
# set up contrasts of interest and recalculate model coefficients # set up contrasts
cts <- c(paste(groups[1],"-",groups[2],sep="")) cts <- c(paste(groups[1],"-",groups[2],sep=""))
cont.matrix <- makeContrasts(contrasts=cts, levels=design) cont.matrix <- makeContrasts(contrasts=cts, levels=design)
fit2 <- contrasts.fit(fit, cont.matrix) fit2 <- contrasts.fit(fit, cont.matrix)
...@@ -57,7 +54,6 @@ write.table(tT, file=stdout(), row.names=F, sep="\t") ...@@ -57,7 +54,6 @@ write.table(tT, file=stdout(), row.names=F, sep="\t")
# Visualize and quality control test results. # Visualize and quality control test results.
# Build histogram of P-values for all genes. Normal test # Build histogram of P-values for all genes. Normal test
# assumption is that most genes are not differentially expressed.
tT2 <- topTable(fit2, adjust="fdr", sort.by="B", number=Inf) tT2 <- topTable(fit2, adjust="fdr", sort.by="B", number=Inf)
hist(tT2$adj.P.Val, col = "grey", border = "white", xlab = "P-adj", hist(tT2$adj.P.Val, col = "grey", border = "white", xlab = "P-adj",
ylab = "Number of genes", main = "P-adj value distribution") ylab = "Number of genes", main = "P-adj value distribution")
......
File deleted
...@@ -2,91 +2,6 @@ ...@@ -2,91 +2,6 @@
## Getting started ## Introduction
All results from the project "Integrative Analysis of miRNA and mRNA Expression Profiles in Squamous Cell Carcinoma" are stored in this GitLab repository
To make it easy for you to get started with GitLab, here's a list of recommended next steps. with the corresponding code snippets
\ No newline at end of file
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://git.imp.fu-berlin.de/aakan96/datascience-ss2023.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://git.imp.fu-berlin.de/aakan96/datascience-ss2023/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment