Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dancelestini authored May 15, 2021
1 parent de65be2 commit cbe9c58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
9 changes: 6 additions & 3 deletions R/DNA_sequence_cos.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#' Obtain all mutations codons
#' Obtain all mutations codons
#'
#' This function will load all the CDS from the mutated genes in the input file. Then recovery the 3' and
#' 5' nucleotide aside of the mutation site.
Expand All @@ -7,8 +7,11 @@
#' @param num The number of patient you want to analyse. Default will go through all the dataset.
#' @return DNA_seq = CDS sequence for all the genes used, codon_part = codon around mutation.
#' @export
DNA_sequence_cos = function(cosmic,num = length(cosmic$GENE_NAME)){

DNA_sequence_cos = function(cosmic,num = length(cosmic$GENE_NAME),random = FALSE){
if (random == TRUE){
idx = sort(sample(1:length(cosmic$GENE_NAME),num, replace = F))
cosmic = cosmic[idx,]
}
genes_mut_names = sapply(strsplit(cosmic$GENE_NAME[1:num],"[\\_]+"), `[`, 1)
genes_mut_site1 = sapply(strsplit(cosmic$MUTATION_CDS[1:num],"[\\c.]+"), `[`, 2)
genes_mut_site = as.numeric(str_extract(genes_mut_site1, "[0-9]+"))
Expand Down
10 changes: 5 additions & 5 deletions R/Signature_algoV2.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
#' @return change_nu = the change of nucleotide due to the mutation, mut_to = the codon paste to
#' the nucleotide after mutation.
#' @export
Signature_algoV2 = function(file,num){
Signature_algoV2 = function(file,num, random = FALSE){
for(i in 1:length(file)){
if( i == 1){
print("Running into file 1")
data = import_data_cos(file[i])
seq = DNA_sequence_cos(data,num)
seq = DNA_sequence_cos(data,num,random)
mut_to = Site_mut_cos(seq)
mut_signa = mut_signature_cos(mut_to, data, i)
mut_signa = mut_signature_cos(mut_to, i)
next
}
print(c("Running into file", i))
data = import_data_cos(file[i])
seq = DNA_sequence_cos(data,num)
seq = DNA_sequence_cos(data,num,random)
mut_to = Site_mut_cos(seq)
mut_signa1 = mut_signature_cos(mut_to, data, i)
mut_signa1 = mut_signature_cos(mut_to, i)
mut_signa = rbind(mut_signa,mut_signa1)
}
mut_signa$cancer = as.factor(mut_signa$cancer)
Expand Down

0 comments on commit cbe9c58

Please sign in to comment.