4.3 Executing the Analysis

Create reward matrices

graph_results<-list()
graph_results  <- lapply(DTAI_AML_samples, function(i){
  mutations <-setdiff(colnames(final_sample_summary[[i]]$NGT),"Clone")
  Known_mat <-final_sample_summary[[i]]$Clones%>%
                                        separate(col=Clone,
                                                 remove = FALSE,
                                                 into=`mutations`)%>%
                                        select(c(all_of(mutations),Clone))%>%
                                        pivot_longer(cols=`mutations`,
                                                     names_to="Genes",
                                                     values_to="Genotype")%>%
                                        pivot_wider(names_from=Clone,
                                                    values_from = Genotype)%>%
                                        mutate_at(vars(-Genes), 
                                                  funs(as.numeric))
                                              
  weights <-final_sample_summary[[i]]$Clones$Count/sum(final_sample_summary[[i]]$Clones$Count)*100
  names(weights)<- final_sample_summary[[i]]$Clones$Clone
  graph_results[[i]]<-create_reward_matrix(Known_mat,weights)
})

names(graph_results) <-DTAI_AML_samples
saveRDS(graph_results,file="graph_results_complete.rds")

Query mutations

graph_results <-readRDS(file="./data/graph_results_complete.rds")

final_results<-list()
for(i in 1:length(graph_results)){
 # print(names(graph_results)[i])
  final_results[[i]]<-query_initiating_mutations(graph_results[[i]])
}
names(final_results) <- names(graph_results)


saveRDS(final_results,file="./data/MDP_trajectory_final.rds")