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

my.rowMeans doesnt work #135

Open
SergejRuff opened this issue Dec 5, 2024 · 0 comments
Open

my.rowMeans doesnt work #135

SergejRuff opened this issue Dec 5, 2024 · 0 comments

Comments

@SergejRuff
Copy link

hello,

In music_S the my.rowMeans doesnt work. It returns teh same as

S <- sapply(unique(clusters), function(ct){
sapply(unique(samples), function(sid){
y = counts(x)[, clusters %in% ct & samples %in% sid]
if(is.null(dim(y))){
return(sum(y))
}else{
return(sum(y)/ncol(y))
}
})
})

instead of

S <- sapply(unique(clusters), function(ct){
my.rowMeans(sapply(unique(samples), function(sid){
y = counts(x)[, clusters %in% ct & samples %in% sid]
if(is.null(dim(y))){
return(sum(y))
}else{
return(sum(y)/ncol(y))
}
}), na.rm = TRUE)
})

is that on purpose or a mistake?

I utilized the single cell dataset from your vignete EMTABsce_healthy.rds.

lib_size <- music_S(x=EMTAB.sce, non.zero=TRUE, clusters='cellType', samples='sampleID',
select.ct=c('alpha', 'beta', 'delta', 'gamma',
'acinar', 'ductal'))

returns

  alpha     beta    delta     gamma    acinar    ductal

1 1112535.6 672700.3 771492.5 441998.45 1931490.1 745700.5
2 950452.0 843435.9 813057.3 656086.57 1082554.4 1065658.7
4 384778.1 362149.6 328635.8 320486.22 540339.3 443171.8
5 263706.3 328880.0 318821.2 270594.95 505857.6 354052.4
6 240645.2 137893.2 250652.9 87412.08 241888.4 371934.3
8 231126.2 139679.5 119419.0 506790.55 112532.5 192096.1

Whereas

EMTAB.sce = EMTAB.sce[, EMTAB.sce@colData[, 'cellType'] %in% c('alpha', 'beta', 'delta', 'gamma',
'acinar', 'ductal')]
x <- EMTAB.sce[rowSums(counts(EMTAB.sce))>0, ]
clusters <- as.character(colData(EMTAB.sce)[, 'cellType'])
samples <- as.character(colData(EMTAB.sce)[,'sampleID'])

S <- sapply(unique(clusters), function(ct){
sapply(unique(samples), function(sid){
y = counts(x)[, clusters %in% ct & samples %in% sid]
if(is.null(dim(y))){
return(sum(y))
}else{
return(sum(y)/ncol(y))
}
})
})

returns

 delta     alpha     gamma    ductal

1 771492.5 1112535.6 441998.45 745700.5
2 813057.3 950452.0 656086.57 1065658.7
4 328635.8 384778.1 320486.22 443171.8
5 318821.2 263706.3 270594.95 354052.4
6 250652.9 240645.2 87412.08 371934.3
8 119419.0 231126.2 506790.55 192096.1
acinar beta
1 1931490.1 672700.3
2 1082554.4 843435.9
4 540339.3 362149.6
5 505857.6 328880.0
6 241888.4 137893.2
8 112532.5 139679.5

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

1 participant