Skip to content

Commit 02cc0c2

Browse files
committed
Added exactCells parameter to the soloBasicCellFilter.awk script tp specify exact number of cells. Parameters can now be specified as variables with awk -v ...
1 parent aa2bdcd commit 02cc0c2

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

extras/scripts/soloBasicCellFilter.awk

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
# usage awk -v exactCells=... -v maxCells=... -v maxPercentile=... -v maxMinRatio=... -f soloBasicCellFilter.awk
12
BEGIN {
2-
maxCells=3000;
3-
maxPercentile=0.99;
4-
maxMinRatio=10;
3+
# default values - if variables were not defined by the user
4+
if (exactCells==0)
5+
exactCells=0;
6+
if (maxCells==0)
7+
maxCells=3000;
8+
if (maxPercentile==0)
9+
maxPercentile=0.99;
10+
if (maxMinRatio==0)
11+
maxMinRatio=10;
12+
13+
print "Parameters: " "exactCells=" exactCells, "maxCells=" maxCells, "maxPercentile=", maxPercentile, "maxMinRatio=", maxMinRatio;
14+
515
nHeaderLines=3;
616
fOutCB=ARGV[1] ".filtered";
717
fOutMat=ARGV[2] ".filtered";
@@ -28,6 +38,9 @@ END {
2838
nMax=cellTotSort[-int((1-maxPercentile)*maxCells)+length(cellTot)];
2939
nMin=nMax/maxMinRatio;
3040

41+
if (exactCells>0)
42+
nMin=length(cellTot)<exactCells ? cellTotSort[1] : cellTotSort[length(cellTot)-exactCells];
43+
3144
nCell=0;
3245
for (ii=1; ii<=length(CB); ii++) {
3346
if (cellTot[ii]>=nMin) {
@@ -38,7 +51,11 @@ END {
3851
};
3952
};
4053

41-
print cellTotSort[length(cellTotSort)]+0,nMax,nMin,nCell;
54+
if (exactCells==0) {
55+
print "maxUMIperCell=" cellTotSort[length(cellTotSort)]+0,"Robust maxUMIperCel=" nMax,"minUMIperCell=" nMin, "Filtered N cells=", nCell;
56+
} else {
57+
print "total N cells=" length(cellTot), "exactCells=" exactCells, "minUMIperCell=" nMin;
58+
};
4259

4360
nMat=0;
4461
for (ii=nHeaderLines+1; ii<=nLines; ii++) {

0 commit comments

Comments
 (0)