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

Extracting Gene-Gene distance matrix from DegPatterns #47

Open
chk63 opened this issue Sep 1, 2021 · 3 comments
Open

Extracting Gene-Gene distance matrix from DegPatterns #47

chk63 opened this issue Sep 1, 2021 · 3 comments

Comments

@chk63
Copy link

chk63 commented Sep 1, 2021

Hello,

I used DegPatterns to cluster my genes which worked, but for upstream analysis I require the gene-gene distance matrix that was used to create these clusters. Is there any way to extract this matrix? Thanks!

@lpantano
Copy link
Owner

lpantano commented Sep 1, 2021

Hey, sorry for the late reply. I think the best way is to do it by yourself since you know the genes.

.summarize_scale <- function(ma, group, scale = TRUE){
    counts_group = t(sapply(rownames(ma), function(g){
        sapply(levels(group), function(i){
            idx = which(group == i)
            mean(ma[g, idx], na.rm = TRUE)
        })
    }))
    colnames(counts_group) = levels(group)
    .logger(head(counts_group), "summarize_scale::counts_group")
    .logger(head(group), "summarize_scale::group")
    if (scale) {
        norm_sign <- t(apply(counts_group, 1, .scale))
    }else{
        norm_sign <- counts_group
    }
    colnames(norm_sign) = colnames(counts_group)
    norm_sign
}
    # ma is the matrix only with your genes of interest 
    # metadata[[summarize]] is the vector with the time or group information matching the samples order in ma
    counts_group <- .summarize_scale(ma,
                                     metadata[[summarize]],
                                     FALSE)

    m <- (1 - cor(t(counts_group), method = "kendall"))
    d <- as.dist(m^2)

I could try to add the output package but not sure when I could do that. Let me know.

@chk63
Copy link
Author

chk63 commented Sep 1, 2021 via email

@lpantano
Copy link
Owner

lpantano commented Sep 4, 2021

mm, not sure what is happening. are you using the function as .summarize_scale with a dot in front of the function? (assuming you have copy/paste my code) i use the door in front of functions to tell they are internal, and I took it directly from the code. Not sure if you tried to use directly like that and then calling it without the dot. Feel free to share the exact code you are using and/or share the R environment with me. Happy to try to help. Cheers

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

2 participants