Skip to content

Instantly share code, notes, and snippets.

View zainabnazari's full-sized avatar
🧮

Zainab Nazari zainabnazari

🧮
View GitHub Profile
#In python instead of
my_list=[]
for i in range(len(my_files)):
my_list=my_list+[my_function(my_files.iloc[i][0])]
my_list;
#use:
my_list = [my_function(my_files.iloc[i][0]) for i in range(len(bl_files))]
@zainabnazari
zainabnazari / git_pro.sh
Last active June 23, 2023 04:14
If you have pushed a large file to a remote repository on GitHub and it was rejected due to file size limitations, you can undo this action by following these steps:
git rm path/to/large_file.ext
# commit the removal:
git commit -m "Remove large file"
# If you want to keep the previous commit message, use:
git commit --amend --no-edit
# oteherwise
git commit --amend
# then:
git push --force origin branch_name
# force pushing can be disruptive and may affect other collaborators who have already pulled the previous commit.
%%time
dfSave = pd.DataFrame()
for i in range(len(bl_files)):
print(i)
df = pd.read_csv(path1/bl_files.iloc[i][0],skiprows=1,delimiter='\t')
dfSave[bl_list[i]] = df.iloc[:,-1:]
del df
@zainabnazari
zainabnazari / hash_value.c
Last active June 28, 2023 05:02
hash value function for a matrix multiplication
// C[] is the elements of matrix multiplication
// we consider the hash value as zero and add the sum of the elemnt of the matrix as its value
// if the two matrices that we have computed have diffrent hash value then there would be an error in the computation of the matrics.
int hash_value = 0;
int i_m;
for( i_m = 0; i_m < N*N; i_m++) {
hash_value += C[i_m];
}
// taking a modulo to shorten the final result.
@zainabnazari
zainabnazari / openmp.c
Created June 28, 2023 05:01
a simple openmp
#include <stdio.h>
#include "omp.h"
void main()
{
printf("hi world from the main function\n");
#pragma omp parallel
{
//#pragma omp critical
{
@zainabnazari
zainabnazari / counts_old.py
Created June 29, 2023 04:28
For the extraction of last column of each patients for the base line visit. (to keep a record)
import pandas as pd
import numpy as np
from pathlib import Path
import functools
# We put the main path to the folder where 'counts' files are there.
path1=Path("/scratch/znazari/PPMI_ver_sep2022/RNA_Seq_data/star_ir2/counts/")
# We read the file: in the bl.txt is written the name of all files.
@zainabnazari
zainabnazari / read_pd.py
Created June 29, 2023 04:42
Some reading strategy
final2=pd.read_csv("final.csv", header=None,index_col=[0])
final=final2.rename(columns=final2.iloc[0]).drop(final2.index[0]).reset_index(drop=True)
@zainabnazari
zainabnazari / null.py
Created June 29, 2023 04:56
if there are null values
result_count_ir3_lb=pd.read_csv(path3/"bl_matrix_counts_ir3.txt",index_col=[0])
result_count_ir3_lb.isnull().values.any()
@zainabnazari
zainabnazari / job_ppmi_matrix.sh
Created June 29, 2023 05:09
old job script for ppmi matrix initialisation
#!/bin/bash
#SBATCH --job-name=v02n
#SBATCH --partition=regular1
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --mem=160G
#SBATCH --cpus-per-task=1
#SBATCH --hint=nomultithread
#SBATCH --time=02:00:00
@zainabnazari
zainabnazari / redo_large_file_push.sh
Created July 3, 2023 15:21
If you push a large file or folder into github and it was rejected
# First, make sure you have a backup of your repository or any important files, as this process is irreversible.
git rm -r folder_name
git commit -m "Remove folder_name from repository"
By default, Git retains the history of commits, even for deleted files or folders.
To delete the history and make it easier to push the changes, you can use the git filter-branch command. Run the following command:
git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch folder_name' --prune-empty --tag-name-filter cat -- --all
Once the filter-branch operation completes, the history of the folder will be deleted. However, the commits are still present in your local repository.
To remove them completely, you can run the following command: