Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

combine multiple samples from one individual into a single tree #5

Open
Gravityzd opened this issue Mar 9, 2024 · 3 comments
Open

Comments

@Gravityzd
Copy link

Hello! I'm interested in merging multiple sample data from the same individual into a single tree. using RedeemR.
Could you please provide guidance on how to achieve this?
Thanks a lot!

@Gravityzd Gravityzd changed the title combined multiple samples from one individual into a single tree combine multiple samples from one individual into a single tree Mar 9, 2024
@chenweng1991
Copy link
Owner

Dear Gravityzd:
Thanks for your feedback. Please try the following function. We will incorporate this function into redeemR soon. Please let me know if it works for you.

Thank you!
Best regards
--Chen

## This function has two parameter, one is a list of redeemR objects (with names for each element), the other is the thr, "S", "LS", etc
combined_redeemR<-function(ob.list,thr){
    ## Combine GTsummary(Add suffix at the end of cell names)
    mutated_list <- lapply(seq_along(ob.list), function(i) {
    x <- ob.list[[i]]@GTsummary.filtered
    suffix <- paste0("_", i)
    x <- mutate(x, Cell = paste0(Cell, suffix))
    return(x)
    })
    combined.GTsummary <- do.call(rbind, mutated_list)
    ## Combine depth
    pos_cov<-ob.list[[1]]@DepthSummary[[1]][,1,drop=F]
    pos_cov$meanCov<-lapply(ob.list,function(x){x@DepthSummary[[1]][,2]}) %>% do.call(cbind,.) %>% rowSums
    ## Combine depth at cell level(Add suffix at the end of cell names)
    mutated_list <- lapply(seq_along(ob.list), function(i) {
    x <- ob.list[[i]]@DepthSummary[[2]]
    suffix <- paste0("_", i)
    x <- mutate(x, V1 = paste0(V1, suffix),Sample=names(ob.list)[i])
    return(x)
    })
    cell_cov<-do.call(rbind, mutated_list)
    combined.DepthSummary<-list(pos_cov,cell_cov)
    names(combined.DepthSummary)<-c("Pos.MeanCov","Cell.MeanCov")
    ## Add attributes
    attr(combined.GTsummary,"depth")<-combined.DepthSummary
    attr(combined.GTsummary, "thr")<-thr
    combined_redeemR<-Create_redeemR(combined.GTsummary)
    return(combined_redeemR)
}

@danielee0707
Copy link

danielee0707 commented Mar 31, 2024

Thank you for posting this. When I ran it on the three datasets followed by steps in Get_Started notebook, I got an error when running Show_Consensus and ComputeRejectRate steps complaining there are no RawGenotypes.Sensitive.StrandBalance files, probably because attr$path is NULL. Are these steps important?

@chenweng1991
Copy link
Owner

Dear @danielee0707
It is ok not running Show_Consensus and ComputeRejectRate. They are not essential. But we will also update when we revise this function and put into the code function in the R package. Thank you

Best
Chen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants