Showing
1 changed file
with
162 additions
and
0 deletions
scripts/mapeo.Rmd
0 → 100644
| 1 | +--- | ||
| 2 | +title: "GH" | ||
| 3 | +author: "EQUIPO 5" | ||
| 4 | +date: "22/4/2020" | ||
| 5 | +output: html_document | ||
| 6 | +--- | ||
| 7 | + | ||
| 8 | +Este script tiene la finalidad de obtener la anotacion en el genoma de Homo sapiens de aquellas coordenadas que corresponden a los genes de interes. | ||
| 9 | + | ||
| 10 | +```{r} | ||
| 11 | +#se mandan a llamar a todas las librerias a utilizar | ||
| 12 | +library(Biobase) | ||
| 13 | +library(IRanges) | ||
| 14 | +library(rtracklayer) | ||
| 15 | +library(GenomicRanges) | ||
| 16 | +library(Rsamtools) | ||
| 17 | +library(ggplot2) | ||
| 18 | +``` | ||
| 19 | + | ||
| 20 | +#Obtenemos la anotación de un genoma | ||
| 21 | +Para tener con que comparar el genoma que vamos a analizar, es necesario tener las coordenadas y la cadena en la que se encuentra las regiones del genoma anotadas, para esto ensembl tiene estos archivos. | ||
| 22 | + | ||
| 23 | + ```{r} | ||
| 24 | + #se descarga el genoma de referencia con sus anotaciones, en este caso fueron obtenidos por ensembl100 | ||
| 25 | +setwd("/home/aschafer/Documentos/Genomicas/Semestre_4/Genomica_humana/Enfermedades_monogenicas") | ||
| 26 | +homoS = import("Homo_sapiens.GRCh38.100.gff3.gz") | ||
| 27 | +head(homoS) | ||
| 28 | +``` | ||
| 29 | + | ||
| 30 | +```{r} | ||
| 31 | +#visualización de los datos que tiene el genoma de referencia. | ||
| 32 | +table(mcols(homoS)$type) | ||
| 33 | +``` | ||
| 34 | + | ||
| 35 | +```{r} | ||
| 36 | +#nos quedamos solo con las columnas que deseamos. | ||
| 37 | +mcols(homoS) = mcols(homoS)[,c("source","type","ID","Name")] | ||
| 38 | +``` | ||
| 39 | + | ||
| 40 | + | ||
| 41 | +#Importamos nuestros datos a analizar | ||
| 42 | +Despues de haber trabajado nuestros datos con bowtie, utilizamos el archivo resultante .bam | ||
| 43 | + | ||
| 44 | +```{r} | ||
| 45 | +#cargamos nuestros datos de las enfermedades monogenicas. | ||
| 46 | +bamFile <- "/home/aschafer/Documentos/Genomicas/Semestre_4/Genomica_humana/Enfermedades_monogenicas/sequences_aligned_A_sort.bam" | ||
| 47 | +informacion <- c("rname", "strand", "pos", "qwidth") | ||
| 48 | +informacion <- ScanBamParam(what = informacion) | ||
| 49 | +bam <- scanBam(bamFile, param = informacion) | ||
| 50 | +lapply(bam, names) | ||
| 51 | +``` | ||
| 52 | + | ||
| 53 | + | ||
| 54 | +```{r} | ||
| 55 | +#Construimos un GRanges | ||
| 56 | +mapGR <- GRanges(seqnames = bam[[1]]$rname, ranges = IRanges(start = bam[[1]]$pos, width = bam[[1]]$qwidth), strand = bam[[1]]$strand) | ||
| 57 | +head(mapGR) | ||
| 58 | +``` | ||
| 59 | + | ||
| 60 | + | ||
| 61 | +#Contamos mapeos dentro de las anotaciones | ||
| 62 | +```{r} | ||
| 63 | +#buscamos en que regiones se traslapan | ||
| 64 | +traslapados <- countOverlaps(homoS, mapGR) | ||
| 65 | +typeCounts <- aggregate(traslapados, by = list("type"=mcols(homoS)$type), sum) | ||
| 66 | +head(typeCounts) | ||
| 67 | +``` | ||
| 68 | + | ||
| 69 | +```{r} | ||
| 70 | +#vamos a graficar todos los resultados obtenidos, pero para eso vamos a juntas todos aquellos que tengan menos de 1000 juntos. | ||
| 71 | +valMin <- 1000 | ||
| 72 | +Cuentas <- typeCounts[typeCounts$x > valMin,] | ||
| 73 | +Cuentas <- Cuentas[order(Cuentas$x),] | ||
| 74 | +Cuentas_totales <- rbind(data.frame("type" = "other", "x" = sum(typeCounts$x[typeCounts$x <= valMin])), Cuentas) | ||
| 75 | +porcentaje <- round(100*Cuentas_totales$x/sum(Cuentas_totales$x), 1) | ||
| 76 | + | ||
| 77 | +#png(filename="/home/aschafer/Documentos/Genomicas/Semestre_4/Genomica_humana/Enfermedades_monogenicas/Grafica1.png", width = 550, height = 400) | ||
| 78 | +pie(Cuentas_totales$x, labels = paste(porcentaje, "%", sep = ""), col = rev(rainbow(nrow(Cuentas_totales))), main="Porcentaje de lecturas totales alineadas por tipo", cex=0.9) | ||
| 79 | +legend("topleft", legend = Cuentas_totales$type, cex = 0.8, fill = rev(rainbow(nrow(Cuentas_totales)))) | ||
| 80 | +#dev.off() | ||
| 81 | +``` | ||
| 82 | +Debido que vimos que los tipos: cromosoma, región biológica, exon, mRNA, gen, cinco prima UTR. No eran tan significativos, decidimos eliminarlos para los próximos análisis. | ||
| 83 | + | ||
| 84 | +```{r} | ||
| 85 | +#graficamos ahora los nuevos datos, pero ahora en lugar de utilizar 1000 como el valor minimo, utilizamos 100. | ||
| 86 | +nuevosDatos <- typeCounts[typeCounts$type != "chromosome" & typeCounts$type != "biological_region" & typeCounts$type != "exon" & typeCounts$type != "mRNA" & typeCounts$type != "gene" & typeCounts$type != "five_prime_UTR",] | ||
| 87 | +colores <- c("violetred1", "dodgerblue4", "green2", "yellow", "red", "steelblue1") | ||
| 88 | +valMin2 <- 100 | ||
| 89 | +nuevas_cuentas <- nuevosDatos[nuevosDatos$x > valMin2,] | ||
| 90 | +nuevas_cuentas <- nuevas_cuentas[order(nuevas_cuentas$x),] | ||
| 91 | +nuevas_cuentas_totales <- rbind(data.frame("type"="other", "x" = sum(nuevosDatos$x[nuevosDatos$x <= valMin2])), nuevas_cuentas) | ||
| 92 | +porcentaje2 <- round(100*nuevas_cuentas_totales$x/sum(nuevas_cuentas_totales$x), 1) | ||
| 93 | + | ||
| 94 | +#png(filename="/home/aschafer/Documentos/Genomicas/Semestre_4/Genomica_humana/Enfermedades_monogenicas/Grafica2.png", width = 550, height = 400) | ||
| 95 | +pie(nuevas_cuentas_totales$x, labels = paste(porcentaje2, "%", sep = ""), cex = 1, main = "Porcentaje de lecturas alineadas por tipo seleccionados", col = colores) | ||
| 96 | +legend("topleft", legend = nuevas_cuentas_totales$type, cex = 0.9, fill = colores) | ||
| 97 | +#dev.off() | ||
| 98 | +``` | ||
| 99 | + | ||
| 100 | +```{r} | ||
| 101 | +# Quitamos las categorías de las antocaciones que son redundantes a la clasificación codificante-no codificante y graficamos ahora los nuevos datos, pero ahora en lugar de utilizar 1000 como el valor minimo, utilizamos 100. | ||
| 102 | +nuevosDatos <- typeCounts[-c(1,2,6,9,11,13,16,24),] | ||
| 103 | +colores <- c("violetred1", "orangered1", "dodgerblue4", "green2", "yellow", "purple", "red", "steelblue1") | ||
| 104 | +valMin2 <- 100 | ||
| 105 | +nuevas_cuentas <- nuevosDatos[nuevosDatos$x > valMin2,] | ||
| 106 | +nuevas_cuentas <- nuevas_cuentas[order(nuevas_cuentas$x),] | ||
| 107 | +nuevas_cuentas_totales <- rbind(data.frame("type"="other", "x" = sum(nuevosDatos$x[nuevosDatos$x <= valMin2])), nuevas_cuentas) | ||
| 108 | +porcentaje2 <- round(100*nuevas_cuentas_totales$x/sum(nuevas_cuentas_totales$x), 1) | ||
| 109 | +total <- sum(nuevosDatos$x) #sacamos el total de lecturas | ||
| 110 | +#establecer el número de lecturas que pertenecen a categorías codificantes | ||
| 111 | +codificante <- nuevosDatos[c(3,6,7),] | ||
| 112 | +codificante <- sum(codificante$x) | ||
| 113 | +#ahora para las no codificantes | ||
| 114 | +no_codificante <- total - codificante | ||
| 115 | +datos_finales<-data.frame("type" = c("codificante", "no codificante"), "x" = c(codificante, no_codificante)) | ||
| 116 | +colores2<-c("slateblue3", "green2") | ||
| 117 | +porcentaje3 <- round(100*datos_finales$x/sum(datos_finales$x), 1) | ||
| 118 | + | ||
| 119 | +#png(filename="/home/aschafer/Documentos/Genomicas/Semestre_4/Genomica_humana/Enfermedades_monogenicas/Grafica2.png", width = 550, height = 400) | ||
| 120 | +#par(mfrow = c(1,2)) | ||
| 121 | +pie(nuevas_cuentas_totales$x, labels = paste(porcentaje2, "%", sep = ""), cex = 0.9, main = "Porcentaje de cada clasificación", col = colores, cex.main = 1) | ||
| 122 | +legend("bottomleft", legend = nuevas_cuentas_totales$type, cex = 1, fill = colores ) | ||
| 123 | +#dev.off() | ||
| 124 | +``` | ||
| 125 | + | ||
| 126 | + | ||
| 127 | + | ||
| 128 | + | ||
| 129 | +Datos recuperados por OMIM | ||
| 130 | +```{r} | ||
| 131 | +no_coding <- sum(20, 15, 9, 7, 4, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 228, 144) | ||
| 132 | +protein_coding <- 14886 | ||
| 133 | +OMIM<- data.frame("type" = c("Regiones codificantes", "Regiones no codificantes"), "x" = c(protein_coding, no_coding)) | ||
| 134 | +``` | ||
| 135 | + | ||
| 136 | +```{r} | ||
| 137 | +#png(filename="/home/aschafer/Documentos/Genomicas/Semestre_4/Genomica_humana/Enfermedades_monogenicas/Grafica4.png", width = 550, height = 400) | ||
| 138 | +OMIM$x | ||
| 139 | +porcentaje4 <- round(100*as.numeric(OMIM$x)/sum(as.numeric(OMIM$x)), 1) | ||
| 140 | +pie(as.numeric(OMIM$x), labels = paste(porcentaje4, "%", sep = ""), cex = 0.9, main = "Porcentaje de regiones codificantes y no codificantes de acuerdo a OMIM y a DISEASE", col = colores2, cex.main = 0.95) | ||
| 141 | +legend("bottomleft", legend = OMIM$type, cex = 0.8, fill = colores2) | ||
| 142 | +#dev.off() | ||
| 143 | +``` | ||
| 144 | + | ||
| 145 | + | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + | ||
| 149 | + | ||
| 150 | + | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + | ||
| 154 | + | ||
| 155 | + | ||
| 156 | + | ||
| 157 | + | ||
| 158 | + | ||
| 159 | + | ||
| 160 | + | ||
| 161 | + | ||
| 162 | + |
-
Please register or login to post a comment