logoplot from df and seqs with custom height
This commit is contained in:
parent
34a2057d29
commit
b5aa524914
3 changed files with 284 additions and 13 deletions
|
@ -155,14 +155,17 @@ 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 of muts 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$Mutationinformation
|
||||
, mcsm_data$Position
|
||||
, mcsm_data$mut_pos_occurrence)
|
||||
|
||||
colnames(mut_pos_occurrence) = c('Mutationinformation', 'position', 'mut_pos_occurrence')
|
||||
#######################################
|
||||
# input file 2: meta data with AFandOR
|
||||
#######################################
|
||||
|
@ -201,8 +204,25 @@ 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$mutation
|
||||
, meta_with_afor$Mutationinformation
|
||||
, meta_with_afor$position
|
||||
, meta_with_afor$sample_pos_occurrence)
|
||||
colnames(sample_pos_occurrence) = c('id', 'mutation', 'Mutationinformation', 'position', 'sample_pos_occurrence')
|
||||
#=======================================================================
|
||||
cat('Begin merging dfs with NAs',
|
||||
cat('Begin merging dfs with NAs'
|
||||
, '\n===============================================================')
|
||||
|
||||
###########################
|
||||
|
@ -313,7 +333,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)'
|
||||
|
@ -414,10 +434,28 @@ for (i in outvars){
|
|||
# alternate way to replace with implicit loop
|
||||
# FIXME
|
||||
#sapply(outvars, function(x, y) write.csv(get(outvars), paste0(outdir, '/', outvars, '.csv')))
|
||||
|
||||
#=======================================================================
|
||||
#%% merging mut_pos_occurrence and sample_pos_occurence
|
||||
# FIXME
|
||||
#cat('Merging dfs with positional frequency from mcsm and meta_data'
|
||||
# , '\nNcol in mut_pos_occurrence:', ncol(mut_pos_occurrence)
|
||||
# , '\nncol in sample_pos_occurence:', ncol(sample_pos_occurrence)
|
||||
# ,'\nlinking col:', intersect(colnames(sample_pos_occurrence), colnames(mut_pos_occurrence))
|
||||
# ,'\nfilename: merged_df4')
|
||||
|
||||
#merged_df4 = merge(sample_pos_occurrence, mut_pos_occurrence
|
||||
# , by = 'position'
|
||||
# , all = T)
|
||||
|
||||
#out_filename4 = 'mut_and_sample_freq.csv'
|
||||
#outfile4 = paste0(outdir, '/', out_filename4)
|
||||
|
||||
#*************************
|
||||
# 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, sample_pos_occurrence)
|
||||
#rm(merged_df4)
|
||||
#%% end of script
|
||||
#=======================================================================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue