logoplot from df and seqs with custom height

This commit is contained in:
Tanushree Tunstall 2020-03-29 17:11:17 +01:00
parent 34a2057d29
commit b5aa524914
3 changed files with 284 additions and 13 deletions

View file

@ -160,7 +160,6 @@ if (max(mcsm_data2$Dis_lig_Ang) < 10){
mcsm_data = mcsm_data2
#!!!!!!!!!!!!!!!!!!!!!
#=======================================================================
# clear variables
rm(mcsm_data2)
@ -173,13 +172,13 @@ head(mcsm_data$Mutationinformation)
orig_col = ncol(mcsm_data)
# get freq count of positions and add to the df
setDT(mcsm_data)[, occurrence := .N, by = .(Position)]
setDT(mcsm_data)[, mut_pos_occurrence := .N, by = .(position)]
cat('Added 1 col: position frequency to see which posn has how many muts'
cat('Added col: position frequency to see which posn has how many muts'
, '\nNo. of cols now', ncol(mcsm_data)
, '\nNo. of cols before: ', orig_col)
pos_count_check = data.frame(mcsm_data$Position, mcsm_data$occurrence)
mut_pos_occurrence = data.frame(mcsm_data$id, mcsm_data$Position, mcsm_data$mut_pos_occurrence)
######################################
# input file2 meta data with AFandOR
@ -205,8 +204,21 @@ str(meta_with_afor)
head(meta_with_afor$Mutationinformation)
meta_with_afor = meta_with_afor[order(meta_with_afor$Mutationinformation),]
head(meta_with_afor$Mutationinformation)
orig_col2 = ncol(meta_with_afor)
# get freq count of positions and add to the df
setDT(meta_with_afor)[, sample_pos_occurrence := .N, by = .(Position)]
cat('Added col: position frequency of samples to check'
,'how many samples correspond to a partiulcar posn associated with muts'
, '\nNo. of cols now', ncol(meta_with_afor)
, '\nNo. of cols before: ', orig_col2)
sample_pos_occurrence = data.frame(meta_with_afor$id, meta_with_afor$position, meta_with_afor$sample_pos_occurrence)
#=======================================================================
cat('Begin merging dfs with NAs',
cat('Begin merging dfs with NAs'
, '\n===============================================================')
###########################
@ -315,7 +327,7 @@ if (identical(sum(is.na(merged_df3$OR))
#=======================================================================
#%% merging without NAs
cat('Begin merging dfs without NAs',
cat('Begin merging dfs without NAs'
, '\n===============================================================')
cat('Merging dfs without any NAs: big df (1-many relationship b/w id & mut)'
@ -378,7 +390,7 @@ if(nrow(merged_df3_comp) == nrow(merged_df3)){
#*************************
# clear variables
rm(mcsm_data, meta_with_afor, foo, drug, gene, gene_match, indir, merged_muts_u, meta_muts_u, na_count, orig_col, outdir)
rm(pos_count_check)
rm(mut_pos_occurrence)
#%% end of script
#=======================================================================