Created
December 4, 2017 21:31
-
-
Save allgenesconsidered/4a344254385678783387ce3f7723735e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Generate combine files | |
| # freq_1 <- read.delim('filter_for_common/dat_vc/BEST1_very_common.tsv', header = T, stringsAsFactors = F) | |
| # freq_1$gene <- 'BEST1' | |
| # freq_2 <- read.delim('filter_for_common/dat_vc/HSPB1_very_common.tsv', header = T, stringsAsFactors = F) | |
| # freq_2$gene <- 'HSPB1' | |
| # freq_3 <- read.delim('filter_for_common/dat_vc/MFN2_very_common.tsv', header = T, stringsAsFactors = F) | |
| # freq_3$gene <- 'MFN2' | |
| # freq_4 <- read.delim('filter_for_common/dat_vc/NEFL_very_common.tsv', header = T, stringsAsFactors = F) | |
| # freq_4$gene <- 'NEFL' | |
| # | |
| # merged <- rbind(freq_1, rbind(freq_2, rbind(freq_3, freq_4))) | |
| # colnames(merged)[5] <- "ID" | |
| # write.csv(merged, 'filter_for_common/dat/domneg_verry_common.csv',row.names = F) | |
| wgs_dat <- read.delim('filter_for_common/dat/wgs_filtered_het.tsv', header = T, stringsAsFactors = F) | |
| merged_targets <- read.csv('filter_for_common/dat/domneg_verry_common.csv', header = T, stringsAsFactors = F) | |
| wgs_dat_filt <- wgs_dat[which(wgs_dat$ID %in% merged_targets$ID),] | |
| wgs_dat_filt <- merge(wgs_dat_filt, merged_targets[,c('ID',"gene",'af',"makes_SpCas9","breaks_SpCas9", "var_near_SpCas9")], by='ID',all.x = T) | |
| #write.table(wgs_dat_filt, file = "filter_for_common/dat/wgs_filtered_het_very_common.tsv", sep = "\t", row.names=FALSE, quote=FALSE) | |
| # chr = 'chr11' | |
| # gen = 'hg38' | |
| # from = 61945821 | |
| # to = 61970461 | |
| # name="BEST1" | |
| chr = 'chr1' | |
| gen = 'hg38' | |
| from = 11978181 | |
| to = 12015515 | |
| name="MFN2" | |
| library(Gviz) | |
| library(GenomicFeatures) | |
| wgs_dat_filt <- dat[which(wgs_dat_filt$CHROM == chr),] | |
| wgs_dat_filt <- wgs_dat_filt[apply(wgs_dat_filt[,grep('SpCas9',names(wgs_dat_filt))], MARGIN = 1, function(x) any(x > 0)), ] | |
| color_list <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#911eb4", "#0072B2", "#D55E00", "#CC79A7", '#cb4154') | |
| wgs_GT <- wgs_dat_filt[,grep('.GT',names(wgs_dat_filt))] | |
| wgs_af <- wgs_dat_filt$af | |
| tracks <- list() | |
| i = 1 | |
| for(name in names(wgs_GT)){ | |
| genotypes = wgs_GT[[name]] | |
| specific_data = c() | |
| for(gen_i in 1:length(genotypes)){ | |
| alleles = unlist(strsplit(genotypes[gen_i], '/')) | |
| if(alleles[1] != alleles[2]){ | |
| specific_data = c(specific_data, wgs_af[gen_i]) | |
| } else { | |
| specific_data = c(specific_data, NaN) | |
| } | |
| } | |
| tracks <- c(tracks,DataTrack(GRanges(seqnames = wgs_dat_filt$CHROM, | |
| ranges = wgs_dat_filt$POS, dat=specific_data), background.title=color_list[i], | |
| name = substr(name,1,5), type=c('p','g'), col=color_list[i], ylim=c(0,1))) | |
| i = i+1 | |
| } | |
| txbd = makeTxDbFromUCSC(gen, "knownGene") | |
| genome <- GeneRegionTrack(txbd, chromosome = chr, start=from, end=to, name = 'Genes') | |
| tracks <- c(tracks, genome) | |
| tracks <- c(tracks, GenomeAxisTrack()) | |
| plotTracks(tracks, from = from, to = to, collapseTranscripts = "longest", transcriptAnnotation = "symbol") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment