Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#!/usr/bin/env Rscript
args = commandArgs(trailingOnly=TRUE)
require(dplyr, quietly = TRUE)
path_interaction.bed= args[1] #'G://Rene.Wiegandt/01_CHiC/04_results/Pipeline_final_results/MyoG_interaction_bed/I17-1299-02-C2C12_Undiff_MyoG_S10_L001_LN405_001.interactions.bed'
path_uropa = args[2] #'G://Rene.Wiegandt/fromMario/MyoG_uropa/I17-1299-02-C2C12_Undiff_MyoG_S10_L001_LN405_001_finalhits.txt'
path_uropa_2 = args[3] #'G://Rene.Wiegandt/fromMario/test_swaped_finalhits.txt'
out_full = args[4] #'G://Rene.Wiegandt/fromMario/test_full.txt'
interaction.bed <- data.table::fread(path_interaction.bed, header = FALSE, sep = '\t')
uropa <- data.table::fread(path_uropa, header = TRUE, sep = '\t')
uropa_2 <- data.table::fread(path_uropa_2, header = TRUE, sep = '\t')
uropa.filtered <- subset(uropa, select = -c(peak_id, peak_center))
uropa.filtered_2 <- subset(uropa_2, select = -c(peak_id, peak_center))
colnames(interaction.bed)[1] <- 'peak_chr'
colnames(interaction.bed)[2] <- 'peak_start'
colnames(interaction.bed)[3] <- 'peak_end'
merged <- merge(interaction.bed,uropa.filtered, by = c('peak_chr', 'peak_start', 'peak_end'), allow.cartesian=TRUE)
merged.filtered <- subset(merged, select = -c(V7))
colnames(merged.filtered) <- c('chromosome_frag_1', 'start_frag_1', 'end_frag_1', 'chromosome_frag_2',
'start_frag_2', 'end_frag_2', 'Score', 'feature_frag_1', 'feat_start_frag_1',
'feat_end_frag_1', 'feat_strand_frag_1', 'feat_anchor_frag_1','distance_frag_1',
'genomic_location_frag_1', 'feat_ovl_peak_frag_1', 'peak_ovl_feat_frag_1', 'gene_id_frag_1',
'gene_name_frag_1', 'gene_type_frag_1', 'level_frag_1', 'transcript_support_level_frag_1',
'transcript_type_frag_1', 'query_frag_1')
colnames(uropa.filtered_2)[1] <- 'chromosome_frag_2'
colnames(uropa.filtered_2)[2] <- 'start_frag_2'
colnames(uropa.filtered_2)[3] <- 'end_frag_2'
merged_interaction_uropa1_uropa_2 <- merge(merged.filtered,uropa.filtered_2, by = c('chromosome_frag_2','start_frag_2','end_frag_2'), allow.cartesian=TRUE)
merged_interaction_uropa1_uropa_2_ordered <- merged_interaction_uropa1_uropa_2[,c( 'chromosome_frag_1', 'start_frag_1', 'end_frag_1', 'chromosome_frag_2',
'start_frag_2', 'end_frag_2', 'Score', 'feature_frag_1',
'feat_start_frag_1', 'feat_end_frag_1', 'feat_strand_frag_1', 'feat_anchor_frag_1',
'distance_frag_1', 'genomic_location_frag_1', 'feat_ovl_peak_frag_1', 'peak_ovl_feat_frag_1',
'gene_id_frag_1', 'gene_name_frag_1', 'gene_type_frag_1', 'level_frag_1',
'transcript_support_level_frag_1', 'transcript_type_frag_1', 'query_frag_1', 'feature',
'feat_start', 'feat_end', 'feat_strand', 'feat_anchor',
'distance', 'genomic_location', 'feat_ovl_peak', 'peak_ovl_feat',
'gene_id', 'gene_name', 'gene_type', 'level', 'transcript_support_level', 'transcript_type', 'query')]
merged_interaction_uropa1_uropa_2_ordered_sorted <- merged_interaction_uropa1_uropa_2_ordered[order(start_frag_1)]
colnames(merged_interaction_uropa1_uropa_2_ordered_sorted) <- c( 'chromosome_frag_1', 'start_frag_1', 'end_frag_1', 'chromosome_frag_2',
'start_frag_2', 'end_frag_2', 'Score', 'feature_frag_1',
'feat_start_frag_1', 'feat_end_frag_1', 'feat_strand_frag_1', 'feat_anchor_frag_1',
'distance_frag_1', 'genomic_location_frag_1', 'feat_ovl_peak_frag_1', 'peak_ovl_feat_frag_1',
'gene_id_frag_1', 'gene_name_frag_1', 'gene_type_frag_1', 'level_frag_1',
'transcript_support_level_frag_1', 'transcript_type_frag_1', 'query_frag_1', 'feature_frag_2',
'feat_start_frag_2', 'feat_end_frag_2', 'feat_strand_frag_2', 'feat_anchor_frag_2',
'distance_frag_2', 'genomic_location_frag_2', 'feat_ovl_peak_frag_2', 'peak_ovl_feat_frag_2',
'gene_id_frag_2', 'gene_name_frag_2', 'gene_type_frag_2', 'level_frag_2', 'transcript_support_level_frag_2', 'transcript_type_frag_2', 'query_frag_2')
data.table::fwrite(merged_interaction_uropa1_uropa_2_ordered_sorted, file = out_full, col.names = TRUE, sep = '\t', na = 'NA', quote = FALSE)