1
$\begingroup$

I have a set of files based on which I expect to load RDS files like R1-Tn5-NHP-55_NA and R1-Tn5-NHP-42_NA but the code is producing just the name of the 55 files not both 55 and 42.

#standardize N set names  
rename_KP_set <- function(sample_name_vector)  {
 new_sample_name_vector <- apply(sample_name_vector, 
      function(x){     
         if (grepl("42",x[3])){     
           c(x[1:3],'55',x[5])
         } else if (grepl("55",x[3])) {
           c(x[1:3],'NHP',x[5])    
         } else if (grepl("55",x[3])){
           c(x[1:3],'NHP',x[5])
 } else
c(x[1:3],'55',x[5])
 }  
}) %>% 
     sapply(paste, collapse='-')   
     return(new_sample_name_vector) 
 }

How I can get separate rds files having 42 and 55 numbers or for that matter any rds with some number attached to them?

I have already posted this question on Stack overflow on February 27th, 2023 but have got no answers so I am reposting that in Stack exchange bioinformatics in search of an answer. Any help on this issue will be considered useful.

$\endgroup$
3
  • 1
    $\begingroup$ Your question has a few wording issues. For example, what do you mean by "...a set of files based on which I expect to load RDS files..."? Provide sample input, expected output and actual output. You'll probably figure out the problem on your own as you prepare these items. $\endgroup$
    – Ram RS
    Mar 6, 2023 at 20:53
  • 1
    $\begingroup$ Please edit your question and provide us with input files and expected output so we can reproduce the problem and test our solutions. We cannot work on a problem if we cannot reproduce it. $\endgroup$
    – terdon
    Mar 7, 2023 at 10:47
  • $\begingroup$ Can you please explain what your function is trying to do? It's not clear to me from just looking at the function. $\endgroup$
    – gringer
    Mar 7, 2023 at 18:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.