phipsonlab / speckle Goto Github PK
View Code? Open in Web Editor NEWR package for analysing single cell data
License: GNU General Public License v3.0
R package for analysing single cell data
License: GNU General Public License v3.0
Is it possible to obtain batch normalized proportions using the propeller package? I have multiple samples from 5 different studies which are integrated using scvi. I would like to perform de novo clustering based on the proportions of 50-60 cell types. Is it possible to retrieve transformed proportions by regressing out the batch effects from the studies?
Thank you!
Best wishes,
Constantinos
Hello,
Thank you for developing this wonderful tool! I'm working with scRNA-seq data. I'm trying to extract the plotting information from plotCellTypeProps by accessing that object's $data so that I can use those cell proportions when making a customized ggplot box-and-whisker plot of cell proportions. The problem is that I want to append the
pbloodImm <- plotCellTypeProps(clusters = bloodImm$RNA_snn_res.0.8, sample = bloodImm$Patient_ID)
Immprops <- pbloodImm$data
Immprops will be used to store the different proportions per cluster and I append Disease subgroup (Control vs Diseased.1 vs Diseased.2) for each patient to that to dodge my box-and-whisker plot later on.
bloodImmprops <- getTransformedProps(clusters = bloodImm$RNA_snn_res.0.8,
sample = rownames([email protected]))
I use bloodImmprops as the prop.list for the propeller.ttest/anova function. rownames([email protected]) are individual cells
The problem is that when I calculate the mean per each unique Cluster + Disease status combination, they are different than the means generated from propeller.ttest/anova and thus do not make sense when I visualize the ggplot with the manually-added p-values.
The bold text is the mean calculated from the plotCellTypeProps data. So for the proportions, Control = 0.084 and Disease = 0.089
Here is the output of the simple propeller function:
We can see that the mean proportions are very similar to the ones I extracted and summarized from the plotCellTypeProp data.
But, when I run propeller.ttest or propeller.anova, I get different means for my groups...
This is the output of propeller.ttest between Control and Disease for cluster 11 - Blood. As we can see, the proportions here differ if different directions since Control = 0.09 and Disease = 0.087
How can this be fixed?
Hello, thank you for this nice package!
I was wondering whether I understand this correctly from the vignette (https://bioconductor.org/packages/devel/bioc/vignettes/speckle/inst/doc/speckle.html):
propeller(clusters=sce_all$cluster, sample=sce_all$sample, group=sce_all$group)
This command calculates:
In my dataset the biological replicates/samples are 'cell_line1', 'cell_line2', 'cell_line3', repeated for 5 different conditions (groups). Can I just indicate in the propeller function 'sample = <Seurat_object$cell_lines>', and the function will for each of the 5 conditions (groups) calculate the mean of 'cell_line1', 'cell_line2', 'cell_line3' (for each of my clusters)?
Thank you so much!
Hi,
Thank you for your package!
I got an error when running propeller.ttest when setting the sex information as covariate.
These are the versions of packages I used
[1] limma_3.54.1 speckle_0.99.7
Here are my 8 samples: four samples (2Female, 2Male) each for two genotypes. I want to test whether cell proportions differ significantly between genotypes taking sex as a covariate.
#sample | genotype | sex |
---|---|---|
2 | mut | F |
2 | mut | M |
2 | wt | F |
2 | wt | M |
Here are my codes:
props <- getTransformedProps(
seurat_obj$seurat_clusters,
seurat_obj$sample_id,
transform="logit")
samples <- read.csv('../GRCm39/samples.csv')
group <- samples$genotype
sex <- samples$sex
design <- model.matrix(~0+group+sex)
mycontr <- makeContrasts(grouphom-groupWT, levels=design)
propeller.ttest(
prop.list = props,
design = design,
contrasts = mycontr,
sort=TRUE)
And got an error for propeller.ttest:
Error in eBayes(fit.cont, robust = robust, trend = trend) :
promise already under evaluation: recursive default argument reference or earlier problems?
This is my design, contr, and str(props):
> design
grouphom groupWT sexM
1 1 0 1
2 0 1 1
3 1 0 0
4 1 0 1
5 0 1 1
6 1 0 0
7 0 1 0
8 0 1 0
attr(,"assign")
[1] 1 1 2
attr(,"contrasts")
attr(,"contrasts")$group
[1] "contr.treatment"
attr(,"contrasts")$sex
[1] "contr.treatment"
> mycontr
Contrasts
Levels grouphom - groupWT
grouphom 1
groupWT -1
sexM 0
> str(props)
List of 3
$ Counts : 'table' int [1:14, 1:8] 2281 8 66 129 138 95 26 36 4 8 ...
..- attr(*, "dimnames")=List of 2
.. ..$ clusters: chr [1:14] "0" "1" "2" "3" ...
.. ..$ sample : chr [1:8] "1" "2" "3" "4" ...
$ TransformedProps: 'table' num [1:14, 1:8] 1.37 -5.82 -3.74 -3.05 -2.98 ...
..- attr(*, "dimnames")=List of 2
.. ..$ clusters: chr [1:14] "0" "1" "2" "3" ...
.. ..$ sample : chr [1:8] "1" "2" "3" "4" ...
$ Proportions : 'table' num [1:14, 1:8] 0.7995 0.0028 0.0231 0.0452 0.0484 ...
..- attr(*, "dimnames")=List of 2
.. ..$ clusters: chr [1:14] "0" "1" "2" "3" ...
.. ..$ sample : chr [1:8] "1" "2" "3" "4" ...
Do you have any idea how to fix this?
Thank you very much!
Hi, Good day, thank you for the nice package.
I have some questions on how to use propller to regress covariants as age and sex in addressing the compositional changes between case and control in scRNAseq.
In your paper you state:
"More complex experimental designs can be accommodated using the propeller.ttest and propeller.anova functions, which have the flexibility to model additional covariates of interest, such as sex or age."
In your vignette, you give examples of modeling categorial covariate and continuous covariates in separate codes.
I have three levels of covariants:
Is it possible to model categorial covariates (disease status, sex), and continuous covariates (age) at the same time ?
I have tried to model pathological status,age and sex at the same time using:
design <- model.matrix(~ 0 + PATH + pair + sex +age)
Best
Moheb
How can I perform a variance stabilizing transformation on the proportions estimated by spacexr?
I have the weight matrix below, where row is spot id, column is cell type name, the number in the matrix is the proportion of cell types estimated by spacexr. The sum of each row should equal 1, and here is not since I didn't copy the complete matrix.
1 2 3 4 5 6 7
TAAGTTGTGAGGCC 2.292692e-01 3.005909e-05 3.005909e-05 3.005909e-05 3.670932e-01 8.926548e-02 3.005909e-05
GTGCCCCTATCCTG 6.675664e-05 6.675664e-05 6.675664e-05 6.675664e-05 1.318198e-01 6.675664e-05 6.675664e-05
ATGTGCCACATCGG 4.807096e-05 4.807096e-05 4.807096e-05 4.807096e-05 4.807096e-05 1.421878e-01 4.807096e-05
CCGCCGTCTCGATG 3.486809e-05 3.486809e-05 3.486809e-05 3.486809e-05 3.377137e-01 1.014989e-01 3.486809e-05
CAGCTCGTGCTTGA 7.590008e-05 5.721524e-02 7.590008e-05 7.590008e-05 8.041539e-02 5.677883e-01 7.590008e-05
GGCTGGCTGAGGCC 3.149211e-01 1.422552e-01 4.985062e-05 4.985062e-05 2.484134e-01 2.703381e-01 4.985062e-05
TAGGCTGAAGACTG 3.297390e-05 7.494110e-02 3.297390e-05 3.297390e-05 4.182647e-01 2.697740e-01 3.297390e-05
CTTCCGGCATGTCC 1.120751e-04 1.120751e-04 1.120751e-04 1.120751e-04 1.525209e-01 1.120751e-04 1.120751e-04
GCCCCCCATCTGCT 5.294217e-05 5.294217e-05 5.294217e-05 9.104908e-03 5.294217e-05 5.294217e-05 5.294217e-05
AGCTTATTACGTTG 2.840802e-01 1.751406e-01 7.671817e-05 7.671817e-05 5.297927e-02 3.203129e-01 7.671817e-05
AAGGTATCTCAACA 5.380602e-05 5.380602e-05 5.380602e-05 5.380602e-05 6.988223e-02 2.613118e-01 1.747145e-01
CGTTACACACCTCA 5.586827e-05 5.586826e-05 4.689468e-02 1.542028e-02 2.801799e-01 2.109863e-01 5.586827e-05
TGGTTGAGCGATCT 8.984323e-05 2.333192e-02 8.984323e-05 8.984322e-05 1.156254e-01 2.123683e-01 8.984323e-05
GTGGAACCAGCCAA 2.007825e-02 2.777721e-01 6.859269e-05 3.259486e-02 2.409382e-01 4.167652e-02 6.859269e-05
CGGCCGTGCCCACC 6.511133e-05 6.511133e-05 6.511133e-05 6.511133e-05 2.127825e-02 1.997856e-01 6.511133e-05
TTCTGGTTTCTGGC 1.322819e-04 6.351707e-02 1.322819e-04 1.322819e-04 1.415326e-01 1.322819e-04 1.005996e-01
CTGATTGTGCTCAT 2.495690e-01 8.105902e-02 9.274481e-05 9.274481e-05 1.988514e-01 2.882024e-01 9.274481e-05
CACATATGCCTCCT 6.145991e-05 6.145991e-05 6.145991e-05 1.072262e-01 6.145991e-05 1.820542e-01 1.421808e-02
TATCTGTGAAGGAC 6.533813e-05 6.533814e-05 6.533813e-05 6.533813e-05 1.564585e-01 6.533813e-05 6.533813e-05
TGACATATTCATCT 9.465732e-05 8.512554e-03 9.465732e-05 3.381593e-03 9.465732e-05 3.107101e-01 9.465732e-05
CGGCTGGCTCGACC 6.702389e-05 6.702389e-05 6.702389e-05 1.869455e-03 6.702389e-05 1.451687e-01 6.702389e-05
AAGGCTCTACATCA 3.417982e-05 3.417982e-05 3.417982e-05 3.417982e-05 4.057332e-01 2.507974e-01 3.417982e-05
TATGCCCAGGACAG 3.380197e-02 5.018601e-03 1.290414e-04 1.290414e-04 1.290414e-04 1.290414e-04 1.290414e-04
ATGAGTCCACATCT 7.904215e-05 7.904215e-05 7.904215e-05 6.282745e-03 1.597886e-01 3.748211e-01 7.904215e-05
ATCTTTCCTTCAAA 8.409195e-05 8.409195e-05 8.409195e-05 8.409195e-05 8.409195e-05 3.419672e-01 8.409195e-05
CTTTTGCTCCGGAA 7.613547e-05 7.613547e-05 7.613547e-05 7.613547e-05 7.613547e-05 4.174179e-01 1.912609e-02
By the way, would the scale.fac value largely affects the test results? In prop.list <- convertDataToList(sexprops,data.type="proportions", transform="logit", scale.fac=174684/20)
vignette, scale.fac seems just equal the total number of cells divided by sample number, which is the mean number of cell for each samples rather than the exact vector of the total number of cells N for each sample.
Hey @bphipson!
I have an interesting case where I have some patient data where specimens were collected pre- and post- treatment. Is it possible to run a paired test in the speckle
framework for looking at compositional changes in a context like this? If so, how would I set that up?
Thanks!
Hi,
Thanks for your efforts with this tool.
It's my first time using propeller but I'm getting this error with my data using command propeller(clusters = as.factor(seu_batch1_cluster_1to6$seurat_clusters), sample = as.factor(seu_batch1_cluster_1to6$orig.ident), group = as.factor(seu_batch1_cluster_1to6$group))
Performing logit transformation of proportions
group variable has > 2 levels, ANOVA will be performed
Coefficients not estimable: DNFB_OT-I HSV_gBT HSV_OT-I
Warning: Partial NA coefficients for 7 probe(s)Coefficients not estimable: DNFB_OT-I HSV_gBT HSV_OT-I
Warning: Partial NA coefficients for 7 probe(s)Error in `[.MArrayLM`(fit, , coef[-1]) :
Subsetting to non-estimable coefficients is not allowed.
Any ideas? I've tried subetting the data so that it has fewer clusters and fewer groups, but no luck.
Strangely, it also fails to show vignettes and I have tried to various installation options shown in the git:
> browseVignettes('speckle')
No vignettes found by browseVignettes("speckle")
Many thanks,
Dan
Here's a link to the Rds file with the data I'm inputting:
https://unimelbcloud-my.sharepoint.com/:u:/g/personal/daniel_rawlinson_unimelb_edu_au/EUxEKhF4lDNFveH_tpzSAdIBAQqQh4pjpPnVwccV5lMnAw?e=wP24kP
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.