jaleesr / BITFAM

BITFAM is a Bayesian approach and platform to infer transcription factor activities within individual cells using single cell RNA-sequencing data. Please see Gao S et al., Genome Research (2021) https://genome.cshlp.org/content/31/7/1296 for details.
31 stars 16 forks source link

BITFAM_weights #5

Closed GBeattie closed 1 year ago

GBeattie commented 1 year ago

Hey,

Loving the package so far! I was hoping to get an idea of the activity of the target genes for the detected TFs, and couldn't find any documentation on it, I then found a (seemingly) undocumented function called BITFAM_weights, which seems to be intended for what I'm looking for, however it pulls an error. I imagine if there's no documentation then it's possible this function is still in development, or maybe there's a better way for me to extract this information. Code and error below, thanks in advance for any assistance!

BITFAM_res <- BITFAM(data = GetAssayData(seu.int, slot = "data"), species = "mouse", scATAC_obj = NA, ncores = 4)
Z <- BITFAM_activities(BITFAM_res)
weights <- BITFAM_weights(BITFAM_list = BITFAM_res)
Error in extract(BITFAM_list$Model, result, "W") : 
  object 'result' not found
GBeattie commented 1 year ago

I think I have found a workaround, I simply removed the need for "results" in the function, not entirely sure what "results" is so I'll not close the issue (as I may have removed something critical for an accurate output). New function below, anyone else uses at own risk!

BITFAM_weights <- function(BITFAM_list){
  result_matrix <- apply(extract(BITFAM_list$Model,"W")[[1]], c(2,3), mean)
  rownames(result_matrix) <- BITFAM_list$Genes
  colnames(result_matrix) <- BITFAM_list$TF_used
  return(result_matrix)
} 
sgao30 commented 1 year ago

Hello,

Thank you so much for trying our package. We believe you are right. The "results" has been removed from the weight function. Thank you again for pointing out this problem! Let us know if you have more questions or ideas!