| Name | Modified | Size | |
---|
| .. | Jan 3, 2025 02:44 AM | | |
| Lec9TB.pdf | Jan 3, 2025 02:43 AM | 1.4 MB | |
| TB-Bio_Info_11.pdf | Jan 3, 2025 02:43 AM | 1.0 MB | |
| Lec8TB.pdf | Jan 3, 2025 02:43 AM | 977.8 KB | |
| Lec10TB.pdf | Jan 3, 2025 02:43 AM | 492.4 KB | |
| Exam-MidEX1.R | Jan 3, 2025 02:44 AM | 6.7 KB | |
| Bio-Lab2.R | Jan 3, 2025 02:44 AM | 2.2 KB | |
| Exam-mid.R | Jan 3, 2025 02:44 AM | 1.7 KB | |
| Lab-Last.R | Jan 3, 2025 02:44 AM | 1.6 KB | |
| Bio-Lab3.R | Jan 3, 2025 02:44 AM | 1.1 KB | |
| Bio-Lab5.R | Jan 3, 2025 02:44 AM | 867 B | |
| Bio-Lab4.R | Jan 3, 2025 02:44 AM | 686 B | |
| Bio_Pr1.R | Jan 3, 2025 02:44 AM | 645 B | |
| Bio-Lab.R | Jan 3, 2025 02:44 AM | 517 B | |
library(HardyWeinberg)
library(genetics)
#############################3
#Genotype frequencies for 70 SNPs related to Alzheimer's disease
data(Alzheimer)
View(Alzheimer)
HWQqplot(X=as.matrix(Alzheimer[,1:3]),logplot=TRUE,pvaluetype="selome",main="Q-Q Plot for HWE")
HWTernaryPlot(X=as.matrix(Alzheimer[,1:3]))
HWGenotypePlot(X=as.matrix(Alzheimer[,1:3]))
data(HapMapCHBChr1)
View(HapMapCHBChr1)
#Biallelic polymorphisms sampled from chromosome
#22 of the CEU population of the 1000 Genomes project.
data(CEUchr22)
View(CEUchr22)
###########################################
data1<-HWData(nm=1000,n=100)
HWAlltests(data1[1,])
HWTernaryPlot(data1)
HWQqplot(X=data1,logplot=TRUE,pvaluetype="selome",main="Q-Q
Plot for HWE")
HWGenotypePlot(data1)
#######################################
geno1<-c("A/A","A/T","T/A","T/T")
nsnp1<-5;nsample<-100
geneA<-matrix(0,nsample,nsnp1)
for(i in 1:nsnp1){
geneA[,i]<-sample(geno1,nsample,replace=TRUE)
}
data<-makeGenotypes(data.frame(geneA))
af<-c()
for(i in 1:ncol(data)){
af[i]<-max(unname(summary(data[,i])$allele.freq[,2]))
}
phwe<-c()
for(i in 1:ncol(data)){
phwe[i]<-HWE.test(data[,i])$test$p.value
}
phwe
plot(af,phwe,pch=16,type="b")
#####################################################3
p<-seq(0,1,0.01)
plot(p, (1-p)^2, ylab ="genotype frequency", main="Under HWE",type="l",
col="blue")
lines(p, 2*p*(1-p),col="green")
lines(p, p^2, col="grey")
legend(0.5,0.95,"genotype =0",lty = 1, col ="blue", bty="n")
legend(0.5,0.85,"genotype =1",lty = 1, col ="green", bty = "n")
legend(0.5,0.75,"genotype =2",lty = 1, col ="grey", bty = "n")
abline(v = 0.5, lty=2)
==================
LAB 5
library(genetics)
library(combinat)
library(LDheatmap)
snp <- 10
sample <- 100
geno <- c( "A/A", "A/T", "T/A", "T/T") # ,"C/G", "C/C", "G/C", "G/G"
APCO3_gene <- matrix(0,sample,snp) #ROW,COL
APCO3_gene #Only Matrix Created
for(i in 1:snp){ # Col - wise Fill
APCO3_gene[,i]<- sample(geno,sample,replace=TRUE)
}
APCO3_gene
summary(APCO3_gene)
APCO3 <- makeGenotypes(data.frame(APCO3_gene)) # Matrix to Genetype
APCO3
r1 <- summary(APCO3)
r1
LDheatmap(APCO3)
LDheatmap(APCO3,color=heat.colors(10),flip=TRUE)
ldt <- LD(APCO3)
LDtable(ldt)
r2 <- ldt$`R^2`
r2
#het <- ldt$
af<- matrix(0,ncol(APCO3),2)
for(i in 1:ncol(APCO3)){
af[i,]<- unname(summary(APCO3[,i])$allele.freq[,2] )
}
af
gf<- list()
for(i in 1:ncol(APCO3)){
gf[i]<- unname(summary(APCO3[,i])$genotype.freq[,2] )
}
gf
Assing...
library(genetics)
library(combinat)
library(LDheatmap)
library(ggplot2)
num_snps <- 100
sample <- 1000
geno <- c( "A/A", "T/A", "T/T" )
APCO3_gene <- matrix(0,sample,num_snps)
#APCO3_gene
set.seed(1234)
for(i in 1:num_snps){
APCO3_gene[,i]<- sample(geno,sample,replace=TRUE, prob = c(0.97, 0.025, 0.005))
}
#Show Matrix gene Data
#APCO3_gene
#summary(APCO3_gene)
APCO3 <- makeGenotypes(data.frame(APCO3_gene)) # Matrix to Genetype
#APCO3
# Calculation of Allele Frequencies
maf <- matrix(0, ncol(APCO3), 1)
for (i in 1:ncol(APCO3)) {
allele_freq <- unname(summary(APCO3[, i])$allele.freq[, 2])
maf[i] <- min(allele_freq)
}
#Show MAF Values
maf
#MAF plot
maf_plot <- data.frame(SNP = 1:length(maf), MAF = maf)
ggplot(maf_plot, aes(x = SNP, y = MAF)) +
geom_bar(stat = "identity", fill = "#32d1bf", color = "black") + # Bar plot
geom_hline(yintercept = 0.02, color = "red", linetype = "dashed", linewidth = 1) + # Horizontal line
labs(title = "Minor Allele Frequency (MAF) Bar Plot",
x = "Number of SNPs",
y = "Minor Allele Frequency (MAF)") + theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
# Heterozygosity (HET) and PIC
het <- numeric(ncol(APCO3))
pic <- numeric(ncol(APCO3))
for (i in 1:ncol(APCO3)) {
het[i] <- unname(summary(APCO3[, i])$Hu)
pic[i] <- unname(summary(APCO3[, i])$pic)
}
#PLOT
# Create data frames for plotting
het_plot <- data.frame(SNP = 1:length(het), HET = het)
pic_plot <- data.frame(SNP = 1:length(pic), PIC = pic)
# Plot HET values
ggplot(het_plot, aes(x = SNP, y = HET)) +
geom_bar(stat = "identity", fill = "skyblue", color = "black") +
labs(title = "Heterozygosity (HET) Bar Plot", x = "Number of SNPs", y = "Heterozygosity (HET)") +
theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
# Plot PIC values
ggplot(pic_plot, aes(x = SNP, y = PIC)) +
geom_bar(stat = "identity", fill = "lightgreen", color = "black") +
labs(title = "Polymorphic Information Content (PIC) Bar Plot", x = "Number of SNPs", y = "PIC") +
theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
#LD Measures:
ld_result <- LD(APCO3)
ld_r2 <- ld_result$`R^2`
ld_d_prime <- ld_result$`D'`
ld_result
#Plot LD Measures
ld_plot <- data.frame(SNP1 = rep(1:nsnp, nsnp), SNP2 = rep(1:nsnp, each = nsnp), R2 = as.vector(ld_r2))
ggplot(ld_plot, aes(x = SNP1, y = SNP2, fill = R2)) +
geom_tile() +
labs(title = "Pairwise LD (R2)", x = "SNP 1", y = "SNP 2") +
theme_minimal() + theme(plot.title = element_text(hjust = 0.5)) +
scale_fill_gradient(low = "white", high = "red")
LDheatmap(data,color=heat.colors(20),flip=TRUE)
#part c (QC Results and Marker Reduction:)
maf_threshold <- 0.02
selected_snps <- which(maf >= maf_threshold)
filtered_snps <- which(maf < maf_threshold) # SNPs to eliminate
# Display results
cat("Total SNPs:", nsnp, "\n")
cat("SNPs passing QC (MAF >= 0.02):", length(selected_snps), "\n")
cat("SNPs eliminated (MAF < 0.02):", length(filtered_snps), "\n")
5--
library(genetics)
library(combinat)
library(LDheatmap)
n <- 100
sample <- 1000
geno <- c( "A/A", "A/T", "T/T") # c( "A/A", "A/T", "T/A", "T/T")
set.seed(100)
snp1<- sample(geno,n,replace=TRUE)
snp1
table(snp1)
set.seed(100)
snp2<- sample(geno,n,replace=TRUE)
phenotype <- c("case","control")
phe<-sample(phenotype,n,replace=TRUE,prob=c(0.5,0.5))
table(phe)
data<-data.frame(phe,snp1,snp2)
tab <- table(data$snp1)
chisq.test(tab)$p.value
tab <- table(data$snp2)
chisq.test(tab)$p.value
6--
library(genetics)
library(combinat)
library(LDheatmap)
library(ggplot2)
num_snps <- 100
sample <- 1000
geno <- c( "A/A", "T/A", "T/T" )
APCO3_gene <- matrix(0,sample,num_snps)
#APCO3_gene
set.seed(1234)
for(i in 1:num_snps){
APCO3_gene[,i]<- sample(geno,sample,replace=TRUE, prob = c(0.97, 0.025, 0.005))
}
#Show Matrix gene Data
#APCO3_gene
#Show summary Data
#summary(APCO3_gene)
APCO3 <- makeGenotypes(data.frame(APCO3_gene)) # Matrix to Genetype
#Show Genetype Matrix Data
#APCO3
# Calculation of Minor allele frequency (MAF)
maf <- matrix(0, ncol(APCO3), 1)
for (i in 1:ncol(APCO3)) {
allele_freq <- unname(summary(APCO3[, i])$allele.freq[, 2])
maf[i] <- min(allele_freq)
}
#Show MAF Values
maf
# Heterozygosity (HET) and PIC
het <- numeric(ncol(APCO3))
pic <- numeric(ncol(APCO3))
for (i in 1:ncol(APCO3)) {
het[i] <- unname(summary(APCO3[, i])$Hu)
pic[i] <- unname(summary(APCO3[, i])$pic)
}
# Show Heterozygosity (HET) and PIC
#het
#pic
#LD Measures:
ld_result <- LD(APCO3)
ld_r2 <- ld_result$`R^2`
ld_d_prime <- ld_result$`D'`
ld_result
#MAF plot
maf_plot <- data.frame(SNP = 1:length(maf), MAF = maf)
ggplot(maf_plot, aes(x = SNP, y = MAF)) +
geom_bar(stat = "identity", fill = "#32d1bf", color = "black") + # Bar plot
geom_hline(yintercept = 0.02, color = "red", linetype = "dashed", linewidth = 1) + # Horizontal line
labs(title = "Minor Allele Frequency (MAF) Bar Plot", x = "Number of SNPs",
y = "Minor Allele Frequency (MAF)") + theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
#PLOT HET and PIC
# Create data frames for plotting
het_plot <- data.frame(SNP = 1:length(het), HET = het)
pic_plot <- data.frame(SNP = 1:length(pic), PIC = pic)
# Plot HET values
ggplot(het_plot, aes(x = SNP, y = HET)) +
geom_bar(stat = "identity", fill = "skyblue", color = "black") +
labs(title = "Heterozygosity (HET) Bar Plot", x = "Number of SNPs", y = "Heterozygosity (HET)") + theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
# Plot PIC values
ggplot(pic_plot, aes(x = SNP, y = PIC)) +
geom_bar(stat = "identity", fill = "lightgreen", color = "black") +
labs(title = "Polymorphic Information Content (PIC) Bar Plot", x = "Number of SNPs", y = "PIC") + theme_minimal() + theme(plot.title = element_text(hjust = 0.5))
#Plot LD Measures
ld_plot <- data.frame(SNP1 = rep(1:nsnp, nsnp), SNP2 = rep(1:nsnp, each = nsnp), R2 = as.vector(ld_r2))
ggplot(ld_plot, aes(x = SNP1, y = SNP2, fill = R2)) +
geom_tile() +
labs(title = "Pairwise LD (R2)", x = "SNP 1", y = "SNP 2") +
theme_minimal() + theme(plot.title = element_text(hjust = 0.5)) +
scale_fill_gradient(low = "white", high = "red")
#LDheatmap(APCO3)
LDheatmap(APCO3,color=heat.colors(5),flip=TRUE)